Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

367.Replace text in multiple files -- How can I replace the 3rd lines of many files to a fixed string?

User: editor -- 2009-12-15
Hits: 145
Type: Replace text in multiple files   
Search all Replace text in multiple files examples
Description:
I have hundreds of files that in different folders with same name fff.txt, in these files, the text in the 3rd lines are different:

the 3rd line in 1st file: <id>33</id>
the 3rd line in 2nd file: <id>25</id>
...

How can I replace the 3rd lines of all these files to <id>1</id>?
Input Sample:
line1
line2
<id>xxx</id>
line4
Output Sample:
line1
line2
<id>1</id>
line4
Answer:
Hint: You need to Download and install "Replace Pioneer" to finish following steps.
Firstly, search the files:
1. Press ctrl-B open "Batch Runner" dialog
2. Click "Search Files" button
* Fill In Filename filter: fff.txt
* Select search Directory to parent folder of all files
* Check Search subdirectory option
* Click 'Search' to search all files, and click "Close" to close search window

Now all files are listed, secondly, make replacement:
3. Click "Fast Replace" to open "Fast Replace" window
4. Click "add", 
* fill in Search like:

* fill in Replace like:

* click 'OK'
5. click 'Start'

Note: 
^((.*?\n){2})[^\n]* is regular expression, matches the first 3 lines.
((.*?\n){2}) matches the first 2 lines, 

Similar Examples:
How to batch replace 'old' to 'new' in many pdf files? (57%)
How to remove the line 10 to 20 from many text files all at once? (55%)
How do I replace all the tags <hr /> in many html files? (55%)
How to replace all "ID" in following xml file with increased ID? (55%)
How to rename many files with the last modified date of the file? (55%)
How to batch remove/delete first 8 lines of many files? (55%)
How to exchange the line 10 and 20 from many text files all at once? (54%)
How to batch replace 'old' to 'new' in many word doc files? (54%)

Check Demo of Replace text in multiple files