-3

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.

Mark
  • 3,609
  • 1
  • 22
  • 33
  • As far as your uses go, this is a solved problem. Just google for any of the bazillion mass file renaming utilities available and pick one. – afrazier May 02 '14 at 17:07
  • i did a thorough search before asking a question but could not find something relevant to my specific problem. Is bazillion name of some software or utility? – user3549869 May 02 '14 at 17:09
  • afrazier means that similar problems has been solved already (a lot) and you should be able to modify an existing solution to fit your needs – Luigi May 02 '14 at 17:14
  • I understand english. Moreover, same and similar are different terms. could have appreciated if this was discussed before giving a negative vote. I am not a script coding expert and hence thought I would get some help here. Nevertheless, I will keep finding a solution until I get one or will do it manually. Thank you. – user3549869 May 02 '14 at 17:18
  • What I mean is that you don't need to script or code anything. Hundreds of tools have already been written to do what you want and more. [Snapfile's Free File Renaming Tools](http://www.snapfiles.com/freeware/system/fwfilerename.html) has over 2 dozen freeware utilities alone. I'm not sure what you were searching for or where, but any major internet search engine will give you useful results just searching for "file renaming software" or any reasonably similar phrase. – afrazier May 02 '14 at 20:16

1 Answers1

0
@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 ECHOed for testing purposes. After you've verified that the commands are correct, change ECHO REN to REN to actually rename the files.

Magoo
  • 77,302
  • 8
  • 62
  • 84