1.

Solve : Searching for str of text in files and exportation?

Answer»

Greetings everyone,

Having a problem finding a way to search through multiple text files for certain strings of text and then exporting those lines of text to a new document in a decent readable format.  Other then opening each file and scrolling through approximently 800-900 lines in each document and copy\paste or rewrite the data in a new file.   I'll give an example just so that if what im trying to do is feasible or not.  Here is what the text files look like when opened.  would like to be able to search for any line that contain:    MSG, or TOOL.


%
 (BI01375)
 N2(MSG,65B04241-9 SN BI01375  1 )
 N3(MSG,04OCT01 MC095 WKW CAO)
 N7(MSG,15:30  Oct.  4, 2001 CHG#7   )
N9G40G90G80G17
 ( MATERIAL LENGTH =  7.610 )
N10G20
N20G10Y.0Z.0L2A.0P1U31.08X-1.54
N30G54
N40G90G0Y.0A.0U-1.55
N50Z19.
N60G1F475.U-1.19
N70M0
N80M45
N90G0U-1.55
N100U-2.3
N110M48
(MSG,LOAD 00000004,L 05.5500,D 00.3750,R 00.0600)
N120T4
N130M6
N140S18000M3
N150M8
N160M38
N170G90G0X1.71Y1.7095A-90.T2
N180G43Z11.55H4
N190( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N200(*****OPERATION    10*****                              )
N210( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N220(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N230( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N240Y-.484A.0
N250G94
N260G1Z5.45F700.
N270X1.7075Y-.4565F150.
N280Y.1925
N290X1.6875Y.2125
N300Y-.484F250.
N310G0Z11.55
N320( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N330(*****OPERATION    20*****                              )
N340( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N350(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N360( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N370A-180.
N380X1.71Y.484
N390G1Z6.8735F700.
N400X1.6875Y.4565F150.



Would like the out put into another text or word\excel to be somewhat in the following format

Filename.XXX
N2(MSG,65B04241-9 SN BI01375  1 )
 N3(MSG,04OCT01 MC095 WKW CAO)
 N7(MSG,15:30  Oct.  4, 2001 CHG#7   )
(MSG,LOAD 00000004,L 05.5500,D 00.3750,R 00.0600)
N220(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N350(TOOL  4 =  .375 DIAMETER ENDMILL                       )

next file.XXX
N2(MSG,65B04241-9 SN BI01375  1 )
 N3(MSG,04OCT01 MC095 WKW CAO)
 N7(MSG,15:30  Oct.  4, 2001 CHG#7   )
(MSG,LOAD 00000004,L 05.5500,D 00.3750,R 00.0600)
N220(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N350(TOOL  4 =  .375 DIAMETER ENDMILL                       )


UNFORTUNATELY we have about 5-600 files to go through with the same process.  Not all of the files have the .txt extension if that makes a difference.  I thought about using the findstr cmd but have no idea on what parameters to use or how to get it to export to a file in a readable format.  If someone has any help or advice i would greatly appreciate it.

Dan






Are the input files all in a single DIRECTORY or do they span multiple directories and sub directories?

If they are not in a single directory is their a source directory where the sub directories start?The files are all in one folder but spread out through out subfolders in that one folder.  i did find one CAVEAT, i need to exclude the text files with extensions of   .mg as these file do contain some of the strings that i am searching for but but not with the information that i need....

I greatly appreciate the help...


DanSo each input file will have a new output file in the same directory?
Could you give me an example of your input file names and how you want the new output file named?Some of the files that will be scanned are  65B04241-9.PPU; 65B17613-44.PPU; 11T5008-010-3.PPU; 11T5008-010-4.PPU.  I was HOPING the output could put into one file instead of one output file for each input file.



Discussion

No Comment Found