I have 233 files where I need to change the file names. Just look for a hyphen (-) in the filename and replace the text from right of the hyphen until dot (.) to left and left of the hyphen right.
Here is a sample filename and the pattern/naming convention used Name Of Movie (9999) - Name of Song.kam where 9999 is the year
All files are of the same pattern. I want to reverse the order to Name of Song - Name Of Movie (9999).kam where 9999 is the year
Note: In the filename, every word after a is in CAPS
If it is not possible, I will have to do it manually. Can someone give me a batch script to execute this or tell me if it is possible to do?
Thank you.
@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
FOR /f "tokens=1,3delims=)-." %%a IN (
'dir /b /a-d "%sourcedir%\*) - *.kam" '
) DO FOR /f "tokens=*" %%u IN ("%%b") DO ECHO REN "%sourcedir%\%%a) -%%b.kam" "%%u - %%a).kam"
GOTO :EOF
This should solve your problem. You'd need to change yur sourcedir of course.
The required REN commands are merely ECHO
ed for testing purposes. After you've verified that the commands are correct, change ECHO REN
to REN
to actually rename the files.