Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1108.Text file parser -- How to extract all lines that contain specified words or phrases?

User: Aaron -- 2013-07-19          << 1107  1109 >>
Hits: 2698
Type: Text file parser   
Search all Text file parser examples
Description:
I would like a script that extracts multiple lines from multiple files based on a keyword or key phrase list. Output files should show lines with keywords in same order as they appear in input file.
Input Sample:
Input:

file1.txt

......car
.........
....travel....
home...
.......
etc.


file2.txt

.......
.......
home...
.......
etc.

file3.txt

travel...
....
travel to Europe...
......
......
etc.

keyword or key phrase file:

home
car
travel to Europe
travel
etc.
Output Sample:
Output files:

file1.txt

......car
....travel....
home...
etc.


file2.txt

home...
etc.

file3.txt

travel...
travel to Europe...
etc.
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. Prepare the keywords file as d:\test\keywords.txt
2. ctrl-h open 'replace' dialogue
* set 'replace unit' to 'Line'
* set 'If=>' to:

* click 'advanced' tab, set 'run following at the beginning of replace' to:

3. click 'batch...' button to open "batch runner" window
4. drag multiple text files to 'batch runner' window
5. click 'batch replace', done!

Note: please make back up in advance.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to extract all lines that contain specific words in a file? (87%)
How to extract all sentences that contain specified words? (83%)
How to extract lines containg specified words from many files? (80%)
How to extract all lines that contain words in a list? (79%)
How to extract all lines by specified words in group? (77%)
How to extract sentences that contain specified words from UTF8 file? (77%)
How to extract all records that contains specified field values? (77%)
How to findout all lines that contain specified words in multiple files? (77%)

Check Demo of Text file parser
Keywords:
phrases  based on  keywords  phrase  the keyword  keyword  specified words  extract all lines  script  scrip  batch replace words based on a file  batch script to extract lines from a text file  extract all lines that contain words  extract lines of text with keyword  order text lines in files  same phrase  batch list same file multiple  batch file input from list text file