User: editor -- 2012-01-26 << 906 908 >> |
Hits: 3694 |
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 |