Search : in
By :

Batch rename using text file for new name

Last answer on Oct 6, 2009 3:53:35 pm BST alan, on May 28, 2009 7:56:38 pm BST 
 Report this message to moderators

Hello,
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?

Configuration: Windows XP Internet Explorer 7.0

Best answers for « Batch rename using text file for new name » in :
Writing in batch in text file Show Writing in batch in text file To write in a file text, you just have to use a redirect: echo text > output_file.txt To write in an existing file: echo " Write at the end of the file ">> output_file.txt
Renaming multiple files in batch Show Renaming multiple files in batch Native features Using a third-party program Renaming a large number of files can quickly become tedious. Fortunately, there are tools to automate this task in many cases: Native features On Windows...
[MySQL]Loading a text file into ue table Show[MySQL]Loading a text file into ue table To load a text file as follows: $ tail /home/user1/test.txt 'name1',1,9 'name2',2,3 'name3',3,54 'name4',4,2 'name5',5,9 In a table defined as follows: CREATE TABLE...
Automatic backup of a Database in SQL EXPRESS 2005 ShowAutomatic backup of a Database in SQL EXPRESS 2005 If you want to automate a backup of a database in SQL Server Express, there is a simple solution using a .bat. file. Create a new text file. This file should contain the following...
Inserting text in a file ShowInserting text in a file Introduction Syntax Introduction It is sometimes useful to insert text in the header of one or more document (s) or in a specific part of the document (before or after a specific line). The publisher of...
Download Join (Merge) Text Files Software ShowDescription The application is designed by Sobolsoft. Simple and easy to use, the application has been awarded from various places. Join Text Files a tool that enables you to merge several files. It allows you to merge multiple text files into a...
Download File Renamer Basic ShowDo not try any more to rename manually all your files in mass after data transfer. File Renamer BASIC is a powerful utility to rename folders, files, films, images, etc… In fact, you can easily rename folders even the entire subfolders of image or...
UNIX - Files ShowIntroduction to UNIX files In UNIX systems any element is represented in the form of a file. All files are architectured around a single tree structure where the base, called the root, is written "/". File types UNIX systems define different...
What is a file? ShowWhat is a file? A file is a suite of binary information, i.e. a suite from 0 to 1. This file may be stored in order to keep a record of this information. A text file is a file comprising characters stored in the form of octets. This file is saved...

1

SenHu, on May 31, 2009 2:23:53 pm BST
  • +3

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:\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.

Sen

Reply to SenHu

2

alan, on Jun 1, 2009 6:36:29 pm BST

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.

Reply to alan

3

SenHu, on Jun 2, 2009 5:08:26 pm BST
  • +1

Alan:

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.
Sen

Reply to SenHu

4

Bookworm, on Jul 30, 2009 5:58:47 pm BST

HI,

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"

Reply to Bookworm

5

SenHu, on Aug 13, 2009 4:07:54 pm BST
  • +1

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.

Sen

Reply to SenHu

6

 DKNSJSU, on Oct 5, 2009 4:31:27 pm BST
  • +1

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?

Thank

DKN

Reply to DKNSJSU