Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Sorting files in windows

Status
Not open for further replies.

DeDogs

Programmer
Jun 27, 2003
6
GB
I am wanting to change the filenames of about 100 mp3's from there name e.g. pual sting - 12.mp3 to numbers progressing from the first mp3 file.

I have a text file with all the filenames in and somehow the program needs to read the first name "pual sting - 12.mp3" find the file in the folder and then change the name to 1 because it is the first one in the list. The next mp3 file called "Blue shoes - 09.mp3 will change to 2.mp3 and so on.

Any ideas on how i can do this and maybe help me out and compile the program too?
would be most helpful.
cheers
 
does the file have the full path of all the songs??
how is the file deliminated??

there are several approaches that may be usefull!

but a little more info will help narow it down!

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
The Great Date Debate Thread222-368305
File Formats Galore @ or
 
The file is like this :-
H:\List\Queen - We Are The Champions.mp3
H:\List\Krafty Kuts - Gimme The Funk.mp3
H:\List\Mike Oldfield - The Sunken Forest.mp3
H:\List\David Blane - Intro.wav
H:\List\Del Amitri - Crashing Down.mp3
H:\List\Fight Club - Space Monkeys.mp3
H:\List\level 42 - children say (slap bass mix).mp3
H:\List\Jamiroquai - Deeper Underground(Instrumental).mp3

Its just a ASCI text file.

If it would be easyer another way please tell me and i can format it how you like
 
ok here goes! its a little sloppy but it should work!

Code:
Option Explicit

Dim fso As Object

Private Sub Command1_Click()
    
    RenameFiles "C:/songlist.txt"
    
End Sub

Private Function RenameFiles(myFilePath As String)
    
    Dim myFF As Integer
    Dim tempString As String
    Dim tempFile As String
    Dim tempPath As String
    Dim fileExt As String
    Dim NewFileName As String
    Dim i As Integer
    Dim j As Integer
    
    Set fso = CreateObject("scripting.filesystemobject")
    
    myFF = FreeFile
    i = 1
    
    Open myFilePath For Input As #myFF
    Do While Not EOF(myFF)
        Line Input #myFF, tempString
        tempString = Trim(tempString)
        If fso.fileexists(tempString) Then
            'this bit is a little messy and may need cleaning up a bit
            For j = Len(tempString) To 1 Step -1
                If InStr(1, Mid(tempString, j, 1), "\") Then
                    tempFile = Mid(tempString, j + 1, Len(tempString) - j + 1)
                    tempPath = Mid(tempString, 1, j)
                    Exit For
                End If
            Next j
            fileExt = Right(tempFile, 4)
            NewFileName = tempPath & i & fileExt
            Name tempString As NewFileName
            i = i + 1
        Else
            MsgBox "File: " & tempString & " Cannot be found.", vbOKOnly, "Error : Missing File"
        End If
    Loop
    
    Close #myFF
    
End Function

hope it makes sense... good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
The Great Date Debate Thread222-368305
File Formats Galore @ or
 
Cheers man im just learning it rite now and dont have the package at home will go into college on tuesday and try it out maybe ask the teacher few things. thanks!
 
Woo Who! got it working perfect and i never had to change a thing! thanks again i cna get my cd-writer in action now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top