2

I wish to rename a group of files in a particular folder in such a way that everything between and including the parenthesis is erased.

For example a file with the name of:

"78 Tax Tips for Canadians for Dummies (ISBN - 0470676582)"

I wish to rename it to:

"78 Tax Tips for Canadians for Dummies"

I need to do this for all the files file in a particular folder for any and all files that follow this same pattern for it's file name characters:

Dummies (ISBN - .........)

I tried following and using the batch script logic on this post but I could not get that to work the number after the ISBN - ########## part keeps changing with the way I did that incorrectly.

  • forgive me but i am not able to figure it out. i request you to give me a command line. – Saransh Reu Feb 1 '16 at 14:17
  • 2
    The link above describes what you want to do with a little bit of tinkering around. That's exactly what you need, a batch script to rename files. – Matt King Feb 1 '16 at 14:20
  • i am someone who is a stranger to coding. i hope you can understand my position. therefore i need a ready made command line. – Saransh Reu Feb 1 '16 at 14:23
  • unlike in the link you mentioned, the number after ISBN - ' ' keeps changing, so i am not able to do it. – Saransh Reu Feb 1 '16 at 14:43
1

Batch file rename, strip off parenthesis and all characters between, but keep extension

Save all the logic from the below example to a text file and name it something.cmd and then simply execute it. . .

Script Notes

  • Where SET RenDir=C:\Path is C:\Path, you'll need to put the full path where these files you wish to rename exist.

  • The assumption with this script logic is there will ONLY be files in the RenDir with parenthesis () that will need to be stripped with the (ISBN - .........) type pattern and no other parts of any of those file names will contain any parenthesis ().

Example Batch Script Logic

@ECHO ON

SET RenDir=C:\Path

FOR /F "DELIMS=() TOKENS=1,3" %%F IN ('DIR /B /A-D "%RenDir%\*.*"') DO (
    CALL :RenameFiles "%%~F" "%%~G"
)
GOTO EOF

:RenameFiles
SET fname=%~1
SET Ext=%~2
REN "%RenDir%\%fname%*%ext%" "%fname%%ext%"
GOTO EOF
| improve this answer | |
  • should i copy and paste the entire code in cmd window ? – Saransh Reu Feb 1 '16 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.