View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Rename Multiple File Names in Windows XP Professional 5.1

Works with Excel 2003 and earlier - if you have Excel 2007, you need to use DIR instead of
FileSearch. Change the folder to your path, or uncomment the Thisworkbook.Path line and store the
file with the macro in the same folder as your BPM files.....

Sub RenameFiles()
Dim oldName As String
Dim newName As String
With Application.FileSearch
.NewSearch
.LookIn = "C:\Folder Name"
'.LookIn = ThisWorkbook.Path
.FileType = msoFileTypeAllFiles
.SearchSubFolders = True ' Careful with this option...
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
If .FoundFiles(i) Like "*\BPM *" Then
newName = Replace(.FoundFiles(i), "\BPM ", "\BPM-")
oldName = .FoundFiles(i)
Name oldName As newName
End If
Next i
End If
End With
End Sub


HTH,
Bernie
MS Excel MVP


"Chilired" wrote in message
...
I have approx 1,000 files in which the file name begins with BPM[space]unique
name.####. I would like to change all of the files to read BPM[dash].unique
name.#### without renaming each file individually. Is this possible?