Search code examples
windowscmdrename

Rename multiple files without parentheses/remove parentheses windows


I want to rename a large number of files in increasing order of numbers, starting from anywhere. But when I rename multiple files, it leaves me with parentheses. eg i rename files to abc_.jpeg it results in abc_(1).jpeg, abc_(2).jpeg and so on.

I tried using command prompt to rename

ren abc_(*).jpeg abc_*.jpeg
doesn't work. probably because of brackets

ren abc_"("*")".jpeg abc_*.jpeg
renames the files, but results in the same file name as before. I just want to remove the parentheses somehow.


Solution

  • To remove the brackets you will have to do some string manipulation. I have written a batch file to do this (save as .bat)

    cd C:\folder
    setlocal enabledelayedexpansion
    for %%a in (abc_*.jpeg) do (
    set f=%%a
    set f=!f:^(=!
    set f=!f:^)=!
    ren "%%a" "!f!"
    )
    

    I don't think you can easily do this in one line from the command line though, it may be possible but it won't be pretty. If you can help it use this batch file to remove the brackets.