Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1109.Text file parser -- For each word in list, how to extract all lines contain the word and save to word.txt?

User: Aaron -- 2013-07-19          << 1108  1110 >>
Hits: 1611
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. I would also save the output files by keyword name. For example, extract all lines from all files with keyword "car" from keywords list into an output file called "car." Same for "travel" "home".
Input Sample:
Input:

file1.txt

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


file2.txt

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

file3.txt

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

keyword or keyphrase file:

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

1. car.txt:
......car

2. home.txt
home...
home...

3. travel.txt
....travel....
travel...
travel to Europe...

4. travel to Europe.txt

travel to Europe...
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
0. to avoid duplicate content, clear all files in destination folder, such as d:\test\ 
1. ctrl-h open 'replace' dialogue
* set "replace unit"  to 'Line'
* set "replace with pattern" to: 
* click 'advanced' tab, set "run following at the beginning of replace" to:

* set "run following for each matched unit" to:

2. click "Batch..." button
3. drag multiple files to "batch runner" window
4. check "set output filename" option, and change the following entry to blank(default is "${FILENAME}"), this step is to avoid original file being overwritten.
5. click "batch replace", all required files will be generated at d:\test\ folder.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to extract all lines that contain words in a list? (65%)
How to extract all lines that contain words A and B and C? (65%)
How to extract all lines containing words in specified file? (63%)
How to extract all lines that contain specific words in a file? (60%)
How to extract all lines do not contain a list of keywords? (59%)
How to extract all lines that contain specified words or phrases? (58%)
How to extract all lines that contain A, but not any of B C D? (57%)
How to extract random lines containing specified words? (56%)

Check Demo of Text file parser
Keywords:
written  based on  keywords  extract all lines contain  phrase  keyword  led  extract all lines  script  scrip  duplicate lines in a file batch file  batch file for extract filename from a list  batch file duplicate lines  extract lines that contain word of list  batch duplicate lines  extract duplicate lines  change beginning of filename  multiple keywords replace