Software to change the filename

April 9, 2010 at 03:41:38
Specs: Windows Vista
I have more than 300 mp3+g files that has filnames like: sf015-10 - midler, bette - rose, the.
I am looking for a way to change the filename to: sf015-10 - bette midler - the rose.
I have looked everywhere, and tryed some filename changer, but I cant find any ways to fix this.
Can anyone help? (Im using Vista Home)

See More: Software to change the filename

Report •


#1
April 9, 2010 at 04:54:57
Are you familiar with Excel VBA?

Do a Google search on this string:

rename files with vba

You'll get tons of hits with examples of code.

Basically you need to loop through the directory and use the Name property. For a single file it would look like:

Sub RenameFile
Name "C:\Documents and Settings\user_name\My Documents\MyOldFileName.xls" _
  As "C:\Documents and Settings\user_name\My Documents\MyNewFileName.xls"
End Sub

Of course, you'll need to build the new FileName string by loading in the old name, rearranging it by finding the commas, etc.

The issue will be if there is no consistency in the FileNames. If you can't search on some consistent character or string to help you rebuild the FileNames, things could get pretty complicated.

If there is nothing common to search on, you could present each FileName in an InputBox and manually enter the changes. When you close the InputBox VBA could pick up the new string as the new FileName.

If you think that what you find via the Google search will help, come on back with specific questions, FileName structures, etc. and we'll see if we can offer any more help.


Report •

#2
April 9, 2010 at 06:52:52
Here's a routine I use to copy and rename a set of files for a new client.

I have a folder (sfol) that contains the 6 .xls files and the 1 .doc file that I need for each client.

The code presents InputBoxes asking for the client's name and the date. (The date defaults to the current date in the format I want.)

Once I enter the client's name and the date, the code creates a folder for the client (dfol), copies the 7 files to that folder and the renames them with the client's name, the date and the string that identifies which file is which.

I've changed the string to a generic String_1, String_2, etc. but I think you'll see what I'm doing as you review the code.

Perhaps you could use this as an example to help you accomplish your goal.

If you decide to try and modify this code, I suggest that you make a backup copy of all of your files before you run it. Since this can not be undone, it would be a shame if the filesnames got so screwed up that they prevented the files from being used again.

Option Explicit
Sub MakeClientFiles()
Dim MyFileName As String
Dim MyFilePath As String
Dim SearchString As String
Dim Client_Name As String
Dim Client_Date As String
Dim sfol As String
Dim dfol As String
Dim fso
Dim x As String

'Get Client Name
  Client_Name = Application.InputBox("Enter Client Name", "Client Name Input", Type:=2)
  If Client_Name = "False" Then Exit Sub
  
'Get File Date
  Client_Date = Application.InputBox("Enter Date (e.g. 2006 11 04)", "Date Input", _
                Default:=Year(Now()) & " " & Month(Now()) & " " & Day(Now()))
  If Client_Date = "False" Then Exit Sub
  
'Create Client Folder
  MkDir "C:\Documents and Settings\user_name\Client Files\" & Client_Name

'Copy Files
  sfol = "C:\Documents and Settings\user_name\Client Files"
  dfol = "C:\Documents and Settings\user_name\Client Files\" & Client_Name
   Set fso = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
         fso.CopyFile (sfol & "\*.*"), dfol

'Set File Path
  MyFilePath = "C:\Documents and Settings\user_name\Client Files\" & _
                   Client_Name & "\"

'Find and Rename Each File
    SearchString = "*String_1*.*"
      MyFileName = Dir$(MyFilePath & SearchString, vbNormal)
      Name MyFilePath & MyFileName As MyFilePath & Client_Name & " " & _
                   Client_Date & " String_1.xls"

    SearchString = "*String_2*.*"
      MyFileName = Dir$(MyFilePath & SearchString, vbNormal)
      Name MyFilePath & MyFileName As MyFilePath & Client_Name & " " & _
                   Client_Date & " String_2.xls"

    SearchString = "*String_3*.*"
      MyFileName = Dir$(MyFilePath & SearchString, vbNormal)
      Name MyFilePath & MyFileName As MyFilePath & Client_Name & " " & _
                   Client_Date & " String_3.xls"

    SearchString = "*String_4*.*"
      MyFileName = Dir$(MyFilePath & SearchString, vbNormal)
      Name MyFilePath & MyFileName As MyFilePath & Client_Name & " " & _
                   Client_Date & " String_4.xls"

    SearchString = "*String_5*.*"
      MyFileName = Dir$(MyFilePath & SearchString, vbNormal)
      Name MyFilePath & MyFileName As MyFilePath & Client_Name & " " & _
                   Client_Date & " String_5.xls"

    SearchString = "*String_6*.*"
      MyFileName = Dir$(MyFilePath & SearchString, vbNormal)
      Name MyFilePath & MyFileName As MyFilePath & Client_Name & " " & _
                   Client_Date & " String_6.xls"
      
   SearchString = "*Notes*.*"
      MyFileName = Dir$(MyFilePath & SearchString, vbNormal)
      Name MyFilePath & MyFileName As MyFilePath & Client_Name & " " & _
                   Client_Date & " Notes.doc"

'Reset Variable
  MyFileName = Dir

End Sub


Report •
Related Solutions


Ask Question