1.

Solve : Extract strings from inside .txt files?

Answer»

Hi,

I have hundreds (SOON to be thousands) of .txt files with the filename OR_00000001.txt, OR_00000002.txt and so on. These files all consist of one single row with fixed length fields.

I'm intrested in two fields inside those files; the first one in position 1, length 10 chrs and the second field in position 35, length 12 chrs.

How do extract the content in those fields from all files and put into a file called OR.txt?

Your best best would be to USE a utility DESIGNED for just such a requirement....

Microsoft give LogParser away for free : http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&DisplayLang=en

It is very very good
Graham Quote from: swede on November 19, 2008, 08:33:36 AM

Hi,

I have hundreds (soon to be thousands) of .txt files with the filename OR_00000001.txt, OR_00000002.txt and so on. These files all consist of one single row with fixed length fields.

I'm intrested in two fields inside those files; the first one in position 1, length 10 chrs and the second field in position 35, length 12 chrs.

How do extract the content in those fields from all files and put into a file called OR.txt?



if %variable% is a line of text, e.g. extracted using FOR, then a substring is defined as %variable:~a,B% where a and b are numbers: a is the offset from the start, [0 is the beginning], and b is the NUMBER of characters.

So the first 10 characters would be %variable:~0,10%

and the 12 characters starting at position 35 would be %variable:~34,12%




Discussion

No Comment Found