samedi 18 avril 2015

Batch script to Split File based on text position in a file

I have below two lines in a file abc.txt


Line 1 :



000000001E3TBRK0279800B0000002952015103000463703000556675000618930000478172000481698000571272000581162000465785000362375000499499


Line 2 :



000000001E3TNSK0279800P0000000012015103000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000


Line 3 :



000000001E3TBRK0279800B0000002952015103000463703000556675000618930000478172000481698000571272000581162000465785000362375000499499


Line 4 :



000000001E3TNSK0279800P0000000012015103000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000


Line 5 :



000000001E3TKSN0279800P0000000012015103000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000


I want these records to be splitted into files based on the text from position 13 to 15.


For example; Line 1 and Line 3 are having BRK in position 13 to 15 and I want these two lines a new file naming abc_BRK:


For example; Line 1 and Line 3 are having NSK in position 13 to 15 and I want these two lines a new file naming abc_NSK:


For example; Line 5 have KSN in position 13 to 15 and I want this one line a new file naming abc_KSN:


Values should be picked dynamically from file and should create files dynamically.


Aucun commentaire:

Enregistrer un commentaire