Tuesday, March 31, 2015

Rename Multiple Files without Parentheses using Bat File

To remove parentheses from multiple files in windows, do the followings:

1. If you have many files like this:
conf (1).jpg
conf (2).jpg
conf (3).jpg
conf (4).jpg
conf (5).jpg
conf (6).jpg

2. Create a bat file. The code for bat file is:



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



save a file as bulk.bat

3. Place the bat file in the same folder that you have multiple files that you want to work on it, and then double click on the batch file, you will see the result like this:

conf 1.jpg
conf 2.jpg
conf 3.jpg
conf 4.jpg
conf 5.jpg
conf 6.jpg

Now you are done.

13 comments:

  1. Hey Veekay,

    I find this very helpful. May I ask you what code should I add to remove also the space between the word and the digit. For example when I use your code it removes the parenthesis like that Photo (1),jpg -> Photo 1.jpg.
    And I want to make it like that Photo1.jpg

    Thank you in advance!

    ReplyDelete
  2. Hey Unknown, :P

    Once you have your files in this format (Photo 1.jpg), you can use the following code to make it like Photo1.jpg using:
    ---------------Copy this code (exclude this line)--------
    :renameNoSpace [/R] [FolderPath]
    @echo off
    setlocal disableDelayedExpansion
    if /i "%~1"=="/R" (
    set "forOption=%~1 %2"
    set "inPath="
    ) else (
    set "forOption="
    if "%~1" neq "" (set "inPath=%~1\") else set "inPath="
    )
    for %forOption% %%F in ("%inPath%* *") do (
    if /i "%~f0" neq "%%~fF" (
    set "folder=%%~dpF"
    set "file=%%~nxF"
    setlocal enableDelayedExpansion
    echo ren "!folder!!file!" "!file: =!"
    ren "!folder!!file!" "!file: =!"
    endlocal
    )
    )

    -----------------Don't copy this line--------------
    Use the same method as before.
    Just copy the above line and create bulk2.bat and execute it.

    Good luck.

    ReplyDelete
  3. how to rename every file, what code should be applied for any file rename, like
    jaipur_(1) to jaipur_1
    rajasthan_(1) to rajasthan_1

    ReplyDelete
  4. tnku very much brother its very helpful

    ReplyDelete
  5. I found a Visual basic script on net , and liked it , helped me to batch rename multiple files , here is the download link and youtube video
    video:
    https://www.youtube.com/watch?v=hEpnGCjBL6I
    Download Link
    http://www.teknohaber.tc/download/download.php?file=Rename_en.zip

    ReplyDelete
  6. viusal basic is corrupted on my windows what to do

    ReplyDelete
  7. Would be nice a tutorial that explains how to change the way explorer rename files without the need to create a batch file.
    I mean changing some registry key or value which makes Explorer get rid of parentheses, without a need of batch files.

    ReplyDelete
    Replies
    1. Yeah... THAT would be nice.

      And the batch way didn't work for me.

      Delete
  8. Replies
    1. This comment has been removed by the author.

      Delete
  9. thanks for sharing very informative article File rename software

    ReplyDelete
  10. It seems that there are lots of people out there (myself included), who have a folder full of files that need mass editing. Writing bat files is for experts and it would be great if there was an app or a feature in file explorer or whatever, but there isn't. I have a large folder full of library files in the format filename1(*******).xxx filename2(******) and so on. I want to remove the brackets and their contents from the filenames, so that they end up as filename1.xxx filename2.xxx and so on. I don't want to change the file names other than remove the brackets and their contents, if this is at all possible. For me it is an impossible task. My only option is to ask you or someone to do your thing. Could you please write a batch file for me also?

    ReplyDelete