Copy substring 30-43; insert lines w/prefix

December 15, 2009 at 12:42:44
Specs: Windows XP
I'd like a batch file to copy a string from position 30 thru 43 and insert it into a new lines under it prefixed with XX1 XX2 XX3.

input filename - A5A_datestamp.txt
file details - 80 char fixed length text file
string position - 30-43 always order number

input file example:
A5ASGXK6240008215125 EA00012FBLEE693391166B A6C 0178008777 SMSAA 0001344
A5ASGXS6240014564796 EA00016FBLEE993390121 A6C 0178008777 SMSAA 0006235
A51SGXS8455006561231 SE00075FBLEE293400166 A6C 0178008777 SMSAA 0000376

Output needed:
A5ASGXK6240008215125 EA00012FBLEE693391166B A6C 0178008777 SMSAA 0001344
XX1FBLEE693391166
XX2FBLEE693391166
XX3FBLEE693391166
A5ASGXS6240014564796 EA00016FBLEE993390121 A6C 0178008777 SMSAA 0006235
XX1FBLEE993390121
XX2FBLEE993390121
XX3FBLEE993390121
A51SGXS8455006561231 SE00075FBLEE293400166 A6C 0178008777 SMSAA 0000376
XX1FBLEE293400166
XX2FBLEE293400166
XX3FBLEE293400166

Any help would be appreciated.


See More: Copy substring 30-43; insert lines w/prefix

Report •


#1
December 16, 2009 at 04:52:20
Call me crazy, but it looks like positions 29-42.

============================
@echo off > newfile & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%a in (mytext) do (
>> newfile echo %%a
set S=%%a
set S=!S:~28,14!
>> newfile echo XX1!S!
>> newfile echo XX2!S!
>> newfile echo XX3!S!
)


=====================================
Helping others achieve escape felicity

M2


Report •

#2
December 16, 2009 at 06:09:04
Actually 29,14 is what I needed. Script works perfect...Thanks M2!

Report •

Related Solutions


Ask Question