| User: editor -- 2009-12-15 << 366 368 >> |
| Hits: 3558 |
| 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" on windows platform 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, |
Screenshot 1: Fast_Replace_Window |