Option Explicit
Dim fsoReader Dim strDir Dim strFrom Dim strTo Dim objFolder Dim varFile Dim strName Dim lngCount
'Initialize strDir = "F:\AudioBooks\Disk 4" strFrom = " - Orphans - Disk 4 - " strTo = "Orphans4 " lngCount = 0
'Confirm values strDir = InputBox("Enter folder", "Bulk rename", strDir) strFrom = InputBox("Rename from", "Bulk rename", strFrom) strTo = InputBox("Rename to", "Bulk rename", strTo)
Set fsoReader = CreateObject("Scripting.FileSystemObject") Set objFolder = fsoReader.GetFolder(strDir)
'Get each file For Each varFile in objFolder.Files 'New name strName = CStr(varFile.Name) strName = Replace(strName, strFrom, strTo)
If CStr(varFile.Name) <> strName Then varFile.Name = strName lngCount = lngCount + 1 End If Next
MsgBox "Done. " & lngCount & " files were renamed"