ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Rename Multiple File Names in Windows XP Professional 5.1 (https://www.excelbanter.com/excel-programming/432326-rename-multiple-file-names-windows-xp-professional-5-1-a.html)

Chilired

Rename Multiple File Names in Windows XP Professional 5.1
 
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?

Bernie Deitrick

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?





All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com