Batch rename using text file for new name

alan - May 28, 2009 at 02:56 PM
 garik - Aug 1, 2015 at 07:26 AM
I am batch exporting filenames and I have no control over the ouput name of each file. I need to rename each filename to a specific standard. I have created a text file that has the exported filename in one column and what the filename should be renamed to in another column.
Is there a way to write a script that can use the text file to lookup the old name and rename it to the new name?

7 replies

Registration date
Friday May 22, 2009
Last seen
February 2, 2010
May 31, 2009 at 09:23 AM
You have the old name and new name in two columns in a file. I will call the file "names.txt". Here is the script that will rename all of them in a batch.

var string names ; cat "names.txt" > $names
while ($names <> "")
    var str line ; lex "1" $names > $line
    var str oldname, newname ; wex "1" $line > $oldname ; wex "1" $line > $newname
    system rename ("\""+$oldname+"\"") ("\""+$newname+"\"")

This script is in biterscripting. You can download it free from . It installs in minutes.

Save the script in file C:\Scripts\rename.txt. Start biterscripting. Enter the following command.

script rename.txt

It will rename all the files one by one. Then export them.

Email me if you need more help.


How are the two columns (oldname, newname) in the list file separated ? By tabs ? Commas ? (If your file names have spaces, the two columns can NOT be separated by spaces.) The script is using the wex command to extract the columns, The $wsep is the variable that contains all possible separators.

If your columns are separated by tabs, add the following one line at the very beginning of the script.
set $wsep = "\t"

If your columns are separated by commas, add the following one line at the very beginning of the script.
set $wsep = ","

That should take care of it.

Feel free to email me further questions.

I am new to biterscripting. I have a same problem and I was trying your solution . It did show me rename and my old name and new name of the files but it was throwing an error "system cannot find the files" I tired copying the files in c:\script also but it didnt work
what should be the path of the old files . I have to rename the batch of ".wav" files. Here si the output when I run the rename .txt files.

script rename.txt
The system cannot find the file specified.

C:\Scripts>rename "NewWaveSound.wav" "sweta.wav"

The system cannot find the file specified.

C:\Scripts>rename "NewWaveSound(3).wav" "pewet.wav"
Hi Bookworm:

Your old file names and new file names are specified without path. So, for biterscripting to find them, biterscripting has to be in the same folder where the old files are. For example, if your old files are all in one folder C:\Folder, add the following command at the top of the rename script.

cd "C:\Folder"

Then the script should work correctly. If the old files are not all in one folder, you would specify the old files with full paths.

Hi I am new to Bat

I want to rename the entire directory below to

"Test_B-S002-43_Again.0249" ----> rename to "B-S002-43_Again.0249"
"Test_B-S002-43_Again.0173" ----> rename to "B-S002-43_Again.0173"
"Test_B-S001-43_Again.0170" ----> rename to "B-S001-43_Again.0170"
"Test_B-S001-43_Again.0172" ----> rename to "B-S001-43_Again.0172"

I try to use the bat above but still not working
Also I want to separte them by "S001" and "S002" copy them two 2 different folder name S001 adn S002

Can you help?



Didn't find the answer you are looking for?

Ask a question
Registration date
Tuesday March 5, 2013
Last seen
March 5, 2013

Mar 5, 2013 at 07:04 AM
i would like to suggest you a program</code>
Hey, don't worry if your file name have spaces, even then you can batch them by using BatchRenameFiles Tool.

Just go for it and let me know.

thanks but there's one problem. My filenames have spaces. I tried using quotes but that did not work. How do I get the script to recognize the spaces in the filenames.