Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

727.Advanced search and replace -- How to save specified lines of text file into different files?

User: park -- 2011-02-27          << 726  728 >>
Hits: 2565
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to delete just one line of one file each time and save the line-deleted file  
to a new name,in a loop from the maximum line to the zero line?
Input Sample:
A file,line number is m,like the below  
m is 5,each time delete just line and  
save the line-deleted file to a new  
file.file name is the line  
number__4.txt.....1.txt,0.txt. 
A.txt 
2007/01/11,4.38,4.42,4.28,4.42,2442496 
.00,0.00 
2007/01/12,4.42,4.64,4.40,4.41,4820221 
.00,0.00 
2007/01/15,4.26,4.63,4.26,4.58,1827455 
.00,0.00 
2007/01/16,4.53,4.68,4.53,4.65,1550442 
.00,0.00 
2007/01/17,4.63,4.69,4.42,4.56,2655067 
.00,0.00
Output Sample:
4.txt 
2007/01/11,4.38,4.42,4.28,4.42,2442496 
.00,0.00 
2007/01/12,4.42,4.64,4.40,4.41,4820221 
.00,0.00 
2007/01/15,4.26,4.63,4.26,4.58,1827455 
.00,0.00 
2007/01/16,4.53,4.68,4.53,4.65,1550442 
.00,0.00 
3.txt 
2007/01/11,4.38,4.42,4.28,4.42,2442496 
.00,0.00 
2007/01/12,4.42,4.64,4.40,4.41,4820221 
.00,0.00 
2007/01/15,4.26,4.63,4.26,4.58,1827455 
.00,0.00 
2.txt 
2007/01/11,4.38,4.42,4.28,4.42,2442496 
.00,0.00 
2007/01/12,4.42,4.64,4.40,4.41,4820221 
.00,0.00 
............
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Assume the target file m.txt need to write to d:\test folder: 
1. ctrl-o open source text file 
2. ctrl-h open 'replace' window 
* click 'advanced' page, copy following code into 'Run following for each matched unit' entry: 
 
3. click 'Replace', check folder "d:\test\", there should be files 1.txt, 2.txt,... m.txt 
 
Note:  
* the folder d:\test\ should be created in advance. 
* use double backslash in the code like d:\\test\\

Screenshot 1:  Replace_Advanced_Window


Similar Examples:
How to split a 100 line text file into 100 text files? (66%)
How to remove duplicate lines in multiple files in different sub-folders? (66%)
How to extract specified lines in different section of text file? (65%)
How to extract specified lines in multiple excel(csv) files? (65%)
How to shuffle specified lines in multiple text files? (65%)
How to batch extract specified lines from a text file? (65%)
How to move the specified line to the end in multiple files? (64%)
How to remove first 8 rows and extract column 5 and 8 into different files? (64%)

Check Demo of Advanced search and replace
Keywords:
loop  zero  maximum  backslash  max  double  slash  write  encoding  coding  for loop  loop search  delete code  copy files different  loop replace  write lines  delete time  delete folder