Solved compare lines in files, copy matches to new

Microsoft Windows server 2003 enterprise
December 5, 2011 at 07:18:07
Specs: Windows 2003 SP2, 32xAMD 2.3 Ghz, 64GB
Looking for help here, please.
I have two text files:
1 - file listing, sample like:

2 - action file, sample like:
u:\sea78\siebsrvr\bin\sseunzip.exe u:\troy_zipped\S_OPTY_ATT_1-2EE1YW8_1-5UOK7X.SAF "u:\troy_unzipped\FX_PTonboarding_formSCOL.xls"
u:\sea78\siebsrvr\bin\sseunzip.exe u:\troy_zipped\S_OPTY_ATT_1-2EP7CT2_1-5W4JSN.SAF "u:\troy_unzipped\Starmine order form.xls"

I would like to script the following:
for each value in <1>, check <2>, and if that value exists, copy the whole line from <2> to a new file <3>.

The filenames in <1> may be of variable length; in <2>, they will always be at position 51.

Any assistance will be much appreciated,
Thanks and regards,

See More: compare lines in files, copy matches to new

Report •

December 5, 2011 at 08:44:34
✔ Best Answer
Not very efficent but effective

@ echo off
for /F "delims=" %%j in (File1.txt) do type File2.txt | find /I "%%j" >> File3.txt

Report •

December 6, 2011 at 02:07:51

Worked first time - you're right, it is a little slow - but to be honest that makes no difference, the main thing is the correct output files have been / are being created, which will make the ultimate file extraction process a lot more effective.

Thank you very much IVO.


Report •
Related Solutions

Ask Question