66 ways to rename multiple text/data/mp3/image files automatically

--- by Mind Pioneer


Have you ever need to rename multiple files like:

* Add a date time for each picture filename
* Add author/album/track to MP3 filenames
* Change html filenames to html title
* Add sequence number of all music files
* Change filename according to special part of file content
* Remove specific part of filename
* ... and so on

The windows application, Replace Pioneer, is designed to support all above batch rename requirement, and finish many other rename tasks that looks like impossible.

No matter how complex the renaming rule is, the procedure is always simple:

(1) Install and Launch "Replace Pioneer" and open "Tools->Batch Runner" menu



(2) Drag all windows files to "Batch Runner" window



(3) Change the "Set output filename" entry to the specific rename rule



(4) Click "File Rename", that's done!





Following are 66 most frequently used rules that will cover 99.9% of your renaming requirements:

[change file extension]old name examplenew name exampleformula
1change extensionfile.txtfile.new${BASE}.new
2insert before extensionfile.txtfile.new.txt${BASE}.new.${EXT}
3add new extensionfilefile.new${FILENAME}.new
[re-organize any part of filename]old name examplenew name exampleformula
4take first 3 charsabc1234.txtabc.txt${BASE}{1,3}.${EXT}
5take last 3 chars1234abc.txtabc.txt${BASE}{-3,-1}.${EXT}
6take 3 ~ 6 charsab1234c.txt1234.txt${BASE}{3,6}.${EXT}
7take 1 ~ -3(3rd from end) charsabcde12.txtabcde.txt${BASE}{1,-3}.${EXT}
8take 3 ~ -3(3rd from end) charsab1234cd.txt1234.txt${BASE}{3,-3}.${EXT}
9first 3 and from the 8th char onabc1234def.txtabcdef.txt${BASE}{1,3}${BASE}{8,-1}.${EXT}
10exchange 1,2 and 3,4 charsabcd.txtcdab.txt${BASE}{3,4}_${BASE}{1,2}.${EXT}
[add sequence number]old name examplenew name exampleformula
11sequence number of 1,2,3 ...any.txtN.txt(N=1,2, ...)#.${EXT}
12sequence number of 0001,0002,0003 ...any.txtN.txt(N=0001,0002,...)####.${EXT}
13sequence number of 3,4,5,...any.txtN.txt(N=3,4, ...)#{3}.${EXT}
14sequence number of 5,7,9,...(start=5,step=2)any.txtN.txt(N=5,7,9,...)#{5,2}.${EXT}
15sequence number of 100,99,98,...(start=100,step=-1)any.txtN.txt(N=100,99,98,...)###{100,-1}.${EXT}
16add sequence number 001,002,... before filenamefile.txtN_file.txt(N=001,002,...)###_${FILENAME}
17append sequence number 001,002,... after filenamefile.txtfile_N.txt(N=001,002,...)${BASE}_###.${EXT}
18change the extension name to sequence 001,002,...file.txtfile.N(N=001,002,...)${BASE}.###
19append sequence aaa,aab,...zzz to filenamefile.txtfile.txt.X(X=aaa,aab,aac,...zzz)${FILENAME}.@@@
20create sequence number of 01_01, 01_02, ... 01_10, 02_01, 02_02,... 02_10, 03_01,03_02,...any.txtM_N.txt(M:01,02,03,...,N:01~10)#<calc(($&-1)/10+1,"02")>_#<calc(($&-1)%10+1,"02")>${EXT}
[string replace with regular expression]old name examplenew name exampleformula
21replace 'old' with 'new' in nameold123.txtnew123.txt${FILENAME}{replace,'old','new'}
22remove any digit in filenameabc123def456.txtabcdef.txt${BASE}{replace,'\d+',''}.${EXT}
23remove digits that as surfixabc123def456.txtabc123def.txt${BASE}{replace,'\d+$',''}.${EXT}
24remove digits that as prefix123abc456.txtabc456.txt${BASE}{replace,'^\d+',''}.${EXT}
25add parenthesis for any numberabc123def456.txtabc(123)def(456).txt${BASE}{replace,'(\d+)','(\1)'}.${EXT}
26remove all parenthesis in filenameabc(123).txtabc123.txt${BASE}{replace,'\((.*?)\)','\1'}.${EXT}
27change all parenthesis to bracketabc(123).txtabc[123].txt${BASE}{replace,'\((.*?)\)','[\1]'}.${EXT}
28exchange parts before and after dashabc-def.txtdef-abc.txt${BASE}{replace,'(.*?)-(.*)','\2-\1'}.${EXT}
29change dash to parenthesisabc-def.txtabc(def).txt${BASE}{replace,'(.*?)-(.*)','\1(\2)'}.${EXT}
30change all spaces to underscoreabc def.txtabc_def.txt${BASE}{replace,'\s+','_'}.${EXT}
[rename from file content]old name examplenew name exampleformula
31change filename to the first word of file contentany.txtfirstword${FILENAME}{file_content,'(\S+)'}
32change filename to the first 60 chars of 1st line of file contentany.txtfirstline(60 letter maximum)${FIRSTLINE}{1,60}
33change filename to the first 60 chars of 2nd line of file contentany.txtsecondline(60 letter maximum)${FILENAME}{file_line,2}{1,60}
34change filename to the title of html fileany.htmlhtmltitle.html${FILENAME}{html_title}{1,20}.html
35change filename to the content between <strong> and </strong>any.htmlstrongcontent.html###_${FILENAME}{file_content,'<strong>(.*?)<\/strong>',undef,10000}.${EXT}
36change filename to the content followed by phase_name inside fileany.htmlphase_name_content.html${FILENAME}{file_content,'phase_name\s*"(.*?)"'}.${EXT}
[rename from file date,time]old name examplenew name exampleformula
37change filename to the date time of fileany.jpg2010-07-01_18:19:20.jpg${FILENAME}{file_time, '%Y-%m-%d_%H:%M:%S'}.${EXT}
38change filename to the date of file plus sequence numberany.jpg2010-07-01(N).jpg(N=01,02,03,...)${FILENAME}{file_time, '%Y-%m-%d'}(##).${EXT}
39append file date to original filenameabc.jpgabc_2010-07-01.jpg${BASE}_${FILENAME}{file_time, '%Y-%m-%d'}.${EXT}
[rename from MP3 file info]old name examplenew name exampleformula
40rename mp3 files to artist-album-track formatabc.mp3artist-album-track.mp3${FILENAME}{mp3_info,'%R-%A-%T'}.mp3
41rename mp3 files to artist-album format with sequence numberabc.mp3artist-album_N.mp3(N=001,002,...)${FILENAME}{mp3_info,'%R-%A'}_###.mp3
42append artist and album after original filenameabc.mp3abc_arrist-album.mp3${BASE}_${FILENAME}{mp3_info,'%R-%A'}.mp3
[rename from image file info]old name examplenew name exampleformula
43rename jpg files by adding sequence and picture width, heightabc.jpgN_W_H.jpg(N=001,002,... W=width, H=height)###_${FILENAME}<img_info($&,'%W_%H')>.${EXT}
44rename gif files by appending width and heightabc.gifabc_WxH.gif(W=width,H=height)${BASE}_${FILENAME}<img_info($&,'%Wx%H')>.${EXT}
[rename from index file/mapping file]old name examplenew name exampleformula
45change the Nth filename to the Nth line of indexfilefile.jpg(sequence number=N)X_(lineN_of_indexfile).jpg(N=file sequence,X=001,002,...)###_#<file_line('indexfile',$match)>.${EXT}
46change the filename by looking up the mapping list in mapfile(1)old.txtnew.txt(old<table>new is defined in mapfile)${BASE}<file_content('mapfile',"(?:\n|^)$match\t([^\n]*)")>.${EXT}
47change the filename by looking up the mapping list in mapfile(2)old.txtnew.txt(old,new is defined in mapfile)${BASE}<file_content('mapfile',"(?:\n|^)$match,([^\n]*)")>.${EXT}
[rename with directory name]old name examplenew name exampleformula
48add the pathname in the front of filenamec:\test\abc\01.jpgabc_01.jpg#<basename(getcwd)>_${FILENAME}
49add the pathname and related sequence no in the front of filenamec:\a\x.jpg, y.jpg c:\b\x.jpg, y.jpga_001.jpg, a_002.jpg, b_001.jpg, b_002.jpg#<sprintf("%s_%03d",$A=basename(getcwd),($A eq $B && $match!=1)?++$I:($I=1),$B=$A)>.${EXT}
50create subfolder and move file in itc:\test\a.txtc:\test\old\a.txt#<scalar(system('mkdir old'),'old')>\${FILENAME}
[rename with Uppler/Lower cases]old name examplenew name exampleformula
51change whole filename to lower caseFILE.TXTfile.txt${FILENAME}{lc}
52change whole filename to upper casefile.txtFILE.TXT${FILENAME}{uc}
53change the first letter to upper casefile.txtFile.txt${FILENAME}{ucfirst}
54change the first letter of each word to upper casetest file.txtTest File.txt${BASE}{replace,'\b\w','\U$&'}.${EXT}
[number calculation and re-formatting]old name examplenew name exampleformula
55change all number in filename to 4 digits formatfile123.txtfile0123.txt${BASE}<replace($match,'(\d+)','${\calc($1,"04d")}')>.${EXT}
56add all number in filename by 3, use 4 digits formatfile123.txtfile0126.txt${BASE}<replace($match,'(\d+)','${\calc($1+3,"04d")}')>.${EXT}
57multiply all number in filename by 2, use 4 digits formatfile123.txtfile0246.txt${BASE}<replace($match,'(\d+)','${\calc($1*2,"04d")}')>.${EXT}
58filename is pure number, add the number by the first number in file content123.txt133.txt(assume first number in file content is 10)${FILENAME}<add(basename($&),file_content($&,'(\d+)'))>.${EXT}
59add leading zeros to make the filename has length of 1012W.txt00012W.txt(total length is 10)${FILENAME}{calc,'010s'}
[generate random letters/words]old name examplenew name exampleformula
60append to filename random letters and digit with length of 5abc.txtabc_xxxxx.txt(xxxxx is random letters/digits)${BASE}_#<rand_str(5,'a'..'z',0..9)>.${EXT}
61rename file to random word from candidate wordsabc.txtN_C.txt(N=001,002,..., C=random of 'RED', 'PURPLE',...)###_#<rand_str(1,'RED','PURPLE','GREEN','BLUE','ORANGE')>.${EXT}
[letter re-mapping]old name examplenew name exampleformula
62change filename by mapping 0-9 to A-J correspondingly0123.jpgABCD.jpg${BASE}<scalar($&=~tr/0-9/A-J/,$&)>.${EXT}
63change filename by mapping 0-4 to 5-9, and 5-9 to 0-4012348888.jpg567893333.jpg${BASE}<scalar($&=~tr/0-4,5-9/5-9,0-4/,$&)>.${EXT}
64change filename by reverse upper and lower casesTELLme.txttellME.txt${BASE}<scalar($&=~tr/A-Za-z/a-zA-Z/,$&)>.${EXT}
[rename just for fun]old name examplenew name exampleformula
65reverse letters of filenamejust for fun.txtnuf rof tsuj.txt${BASE}{chars_r,1,-1}.${EXT}
66double each letter in filenamejust for fun.txtjjuusstt ffoorr ffuunn.txt${BASE}{replace,'(.)','\1\1'}.${EXT}

All file rename examples: http://www.mind-pioneer.com/services/conv_search.php?type=Batch file rename

Original link of this article: http://www.mind-pioneer.com/replace/batch_file_rename_ways.html