I presume you’ve got a lot of file names. 10, 100 or 1000?
Start up command prompt (cmd.exe) and run as administrator.
Go to directory where your files are. Let’s presume C:\temp
Type dir /b
Look for the little black icon at the top left
Choose Edit | Mark. You can now select your files.
Choose Edit | Copy
Go to Excel and start up a new workbook and select A1
Hit Paste
Now suppose your file name is something like: Fortitude.S01E01.WEB-DL.XviD-FUM.srt
and you want to replace the part “WEB-DL.XviD-FUM” with “tvshow” (without quotes.)
Go to B1 and enter formula =SUBSTITUTE(A1;”WEB-DL.XviD-FUM”;”tvshow”) Attention, I use semi colon and not comma because I have Dutch version.
Copy down
Now you have your correct file names in B1
Copy and Paste this code in a new module -> Alt+F11 | Insert | Module
Run the code with View | Macros |View macros | RenameFiles | Run
it will pause and you have to point to the directory where your files are.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Sub RenameFiles() Dim xDir As String Dim xFile As String Dim xRow As Long With Application.FileDialog(msoFileDialogFolderPicker) .AllowMultiSelect = False If .Show = -1 Then xDir = .SelectedItems(1) xFile = Dir(xDir & Application.PathSeparator & "*") Do Until xFile = "" xRow = 0 On Error Resume Next xRow = Application.Match(xFile, Range("A:A"), 0) If xRow > 0 Then Name xDir & Application.PathSeparator & xFile As _ xDir & Application.PathSeparator & Cells(xRow, "B").Value xFile = Dir Loop End If End With End Sub |

Result:
