Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

252.Batch file rename -- How to rename all txt files in many folders with format of "folder_(file_id).txt"?

User: editor -- 2008-08-18          << 251  253 >>
Hits: 2538
Type: Batch file rename   
Search all Batch file rename examples
Description:
How to rename all txt files in many folders with format of "folder_id.txt"?
Input Sample:
before rename: 
 
folder1/aaa.txt 
folder1/bbb.txt 
 
folder2/aaa.txt 
folder2/ccc.txt 
folder2/ddd.txt
Output Sample:
after rename: 
 
folder1_1.txt 
folder1_2.txt 
 
folder2_1.txt 
folder2_2.txt 
folder2_3.txt
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
This is a complicate case, but can be finished with "Replace Pioneer": 
1. Open "File->Load->DOS Command" menu,  
enter DOS command as: 
 
fill in the working directory, and click "OK", all files will be listed in the edit window. 
2. Ctrl-h open "Replace" dialog 
* Set Replace Unit to "Line" 
* Set Replace with pattern to: 
 
* Select "Advanced" page, set "Run following for each matched Unit" to: 
 -- this is perl syntax, parsing filename and generate a new name. 
3. Click "Replace", the batch commands are generated. 
4. Save the scripts to run.bat, and run it at DOS prompt of windows.
Download Script:  scripts/252.rst.zip

Similar Examples:
How to rename many files to the format of file.number.ext? (61%)
How to merge files in all folders into one folder? (57%)
How to search all jpg files in subfolders and copy to a new folder? (57%)
How to move a list of files that in different folders to a common folder? (56%)
How to remove all folders in a list containg folders and files? (56%)
How to batch rename files in different folders and move them to a common folder? (56%)
How to join all text file in a folder and remove all blank lines? (55%)
How to batch rename text files with random line from file contents? (55%)

Check Demo of Batch file rename
Keywords:
scripts  many folders  commands  dos command  dos  perl  syntax  tax  batch command  folders  windows prompt batch rename  perl for windows  batch file edit all files in directory  perl command  all batch commands  for each file in directory and batch file filename  directory format  batch file commands