Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

907.Replace text in multiple files -- How to search replace multiple files with distinct search replace definition for each?

User: editor -- 2012-01-26          << 906  908 >>
Hits: 3492
Type: Replace text in multiple files   
Search all Replace text in multiple files examples
Description:
How to search and replace 30000 files, each one has distinct definition of search/replace strings. 
There is a file search_replace.txt with 30000 lines: 
line1 define 36 old text and 36 new text for search and replace in file1 
line2 define 36 old text and 36 new text for search and replace in file2 
... 
line30000 define 36 old text and 36 new text for search and replace in file30000
Input Sample:
1. 30000 html files for replace 
2. file search_replace.txt with following content: 
old1_1 old1_2 ... old1_36 new1_1 new1_2 ... new1_36 
old2_1 old2_2 ... old2_36 new2_1 new2_2 ... new2_36 
old3_1 old3_2 ... old3_36 new3_1 new3_2 ... new3_36 
.... 
old30000_1 old30000_2 ... old30000_36  new30000_1 new30000_2 ... new30000_36
Output Sample:
for file1.html: 
replace old1_1 with new1_1 
replace old1_2 with new1_2 
... 
replace old1_36 with new1_36 
 
... ... 
for file30000.html: 
replace old30000_1 with new30000_1 
replace old30000_2 with new30000_2 
... 
replace old30000_36 with new30000_36 
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
assume the search replace definition file is: 
d:\test\search_and_replace.txt 
 
1. ctrl-h open 'replace' dialogue 
2. set 'replace with pattern' to: 
 
3. click 'advanced' tab: 
* set 'run following for each matched unit' to: 
 
4. click 'batch...' button to open 'batch runner' 
5. click 'search files' 
* set 'file name filter' to  
* enter correct search directory 
* check 'search subdirectory' if required 
* click 'search' to get all files into list 
* click 'close' 
6. make sure the 30000 files are sorted as prefered order. 
7. click 'batch replace', all files will be replaced. 
 
Note:  
* You should make backup in advance to avoid misoperation 
* You should use double backslash for file path seperator in step 3, such as 'd:\\test\\search_and_replace.txt' 

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to search and replace multiple file with multiple regex rules? (64%)
How to search and replace multiple files with rules different in sequence number? (64%)
How to search/replace multiple text files base on rules from csv file? (63%)
How to search and replace in multiple files base on user-defined mapping file? (63%)
How to replace strings in multiple files based on the search/replace mapping file? (63%)
How to search and replace with multiple mapping rules by regular expression? (62%)
How to batch combine multiple files into single files? (59%)
How to batch replace files and save the result to new files? (55%)

Check Demo of Replace text in multiple files
Keywords:
asp  definition  iso  subdirectory  file name filter  backup  backslash  double  path  slash  batch replace backslash with tab  batch file get all files of directory  list new files in directory with batch  batch get list of new files  replace text definition  batch file get files in directory  batch file get directory  double backslash batch