Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Dallas, Texas, USA
    Thanked 1 Time in 1 Post

    Making a txt file...

    Mods, This may belong in another forum...

    I need help creating a txt file that is based on the contents of a folder. I have a lyrics program that will display the lyrics of the mp3 file that is playing. But, in order for the lyrics to load, the file must be present in the index file.

    In a folder Cocuments and SettingsRickyMy DocumentsLyrics, I have over 4,100 txt files that are in the format: Artist - Title.mp3.txt

    I need to write an index file [or just an additional txt file, notepad style] that has each of the 4,100 lyrics files listed. When the index file is written correctly, it will look like this:

    <pre>"Van Mccoy - The Hustle.mp3" "Van Mccoy" "The Hustle"
    "Kid Rock - Picture.mp3" "Kid Rock" "Picture"
    "George Strait - Write This Down.mp3" "George Strait" "Write This Down"
    "John Sebastian - Welcome Back.mp3" "John Sebastian" "Welcome Back"

    Does anyone know of a program or perhaps an MSOffice macro that will generate a txt file like that shown? Again, the source will be the contents of the lyrics folder where the file names are just as described above. It looks like something that MSWord could probably do, but I have no idea where to even start...
    Attached Files Attached Files
    - Ricky

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Making a txt file...

    The following macro can be pasted into a module in any Office application (Word, Excel, ...):

    Sub CreateIndex()
    ' Substitute correct path, it MUST include the trailing backslash
    Const strPath = "Cocuments and SettingsRickyMy DocumentsLyrics"

    Dim f As Integer
    Dim strFile As String
    Dim strMP3 As String
    Dim strArtist As String
    Dim strSong As String

    On Error GoTo ErrHandler

    f = FreeFile
    Open strPath & "Index.txt" For Output As #f
    strFile = Dir(strPath & "*.mp3.txt")
    Do While Not strFile = ""
    strMP3 = Left(strFile, Len(strFile) - 4)
    strArtist = Left(strMP3, InStr(strMP3, " - ") - 1)
    strSong = Mid(strMP3, InStr(strMP3, " - ") + 3)
    strSong = Left(strSong, Len(strSong) - 4)
    Print #f, Chr(34) & strMP3 & Chr(34) & " " & _
    Chr(34) & strArtist & Chr(34) & " " & _
    Chr(34) & strSong & Chr(34)
    strFile = Dir

    On Error Resume Next
    Close #f
    Exit Sub

    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Dallas, Texas, USA
    Thanked 1 Time in 1 Post

    Leo's Lyrics

    Hans: As usual, your macro has worked flawlessly and I sure do appreciate the help.
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    For those interested...

    Leo's Lyrics has a plug-in for WinAmp that will display the lyrics for a song as it is being played. The plugin will search Leo's site for the lyrics and then save it as a txt file to your hard drive in the WinAmp|Plugin directory. As the lyrics database file is developed on your hard drive, so is the index file. Now, every time you play a song, the Lyrics plugin will check it's index file first to see if the lyrics already resides on your system; if not, it will search Leo's site...

    In my case, I already had several thousand lyrics files on hand. I just needed a way to manipulate the index file. And Hans' macro did just that. Awesome!
    - Ricky

  4. #4
    5 Star Lounger
    Join Date
    Apr 2003
    Hampshire, United Kingdom
    Thanked 0 Times in 0 Posts

    Re: Leo's Lyrics

    For anyone without MS Office, (or VBA-phobes) there are also a few stand-alone applications that do this. There was a good one called Xprint, but I haven't been able to find it for a while.

    Also, if you're using Windows XP, there are some command-line switches that may be useful:
    <UL><LI><post#=483783>post 483783</post#>
    <LI><post#=415428>post 415428</post#>[/list]Other utilities to try...
    <UL><LI><post#=281707>post 281707</post#>
    <LI><post#=276818>post 276818</post#> Karen's Directory Printer
    <LI><post#=276998>post 276998</post#> Treeprint[/list]There's plenty more - search the Lounge for "directory listing"
    If at first you do succeed, you&#39;ve probably missed something.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts