Batch to rename using text file for new name

August 2017


Issue

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?

Solution

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 <> "")
do
var str line ; lex "1" $names > $line
var str oldname, newname ; wex "1" $line > $oldname ; wex "1" $line > $newname
system rename ("""+$oldname+""") ("""+$newname+""")
done



This script is in biterscripting.

You can download it free from http://www.biterscripting.com . It installs in minutes.

Save the script in file C:Scriptsrename.txt. Start biterscripting. Enter the following command.


script rename.txt



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

Note

Thanks to SenHu for this tip on the forum.

Related


Published by aakai1056. Latest update on October 8, 2014 at 06:29 AM by Jeff.
This document, titled "Batch to rename using text file for new name," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).