Page 1 of 1

Dos script to edit a variable text file

Posted: 23 Feb 2011 17:42
by kr1
Sorry this looks a bit long, but most of it is example data...
I've never used a bat file, so please excuse my ignorance if this is easy to people who are more familiar with this.

I'm not a programmer, I just have files of text data that I wish to interogate and manipulate.

I am try ing to use a find to then go on and potentailly copy some data from a string of text where the string of text preceeding the data I wish to copy is variable. The only constants are that the first three charachters (alpha) will be constant and the string of text will have the same amount of + signs within it.

I want to be able to populate the 6 numberics which appear after the fourth + sign onto each line below it, up to the part where you reach END=n'


Does this make sense? If so can any one help me?

Example data below

Starting data

LMN=ABC:1+BBBB:COULD SAY AN+ZSED:COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+123456+AAAAAAA+ANYVALUES+A'
STRING OF TEXT1
STRING OF TEXT2
STRING OF TEXT3
STRING OF TEXT4
STRING OF TEXT5
END=5'
LMN=ABC:1+C00016:DIFFERENT VALUES INC SPACES+Z00123:D COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+000001+AAAAAAA+ANYVALUES+A'
STRING OF TEXT1
STRING OF TEXT2
STRING OF TEXT3
END=3'
LMN=FED:1+EDRE:COULD SAY ANYTHING INCLUDING SPACES+FERD:COULD SAY ANSPACES+DDMMYYYY:HHMMSS+9999+AAAAAAA+ANYVALUES+A'
STRING OF TEXT1
END=1'
LMN=XYZ:5+BZER:ANYTHING+B456:OTHE TEXT+DDMMYYYY:HHMMSS+801207+JHYTHGH+JUHY01+T'
STRING OF TEXT1
STRING OF TEXT2
STRING OF TEXT3
STRING OF TEXT4
STRING OF TEXT5
STRING OF TEXT6
STRING OF TEXT7
STRING OF TEXT8
END=8'



I want this to be amended this to look like this;

LMN=ABC:1+BBBB:COULD SAY AN+ZSED:COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+123456+AAAAAAA+ANYVALUES+A'
123456 STRING OF TEXT1
123456 STRING OF TEXT2
123456 STRING OF TEXT3
123456 STRING OF TEXT4
123456 STRING OF TEXT5
END=5'
LMN=ABC:1+C00016:DIFFERENT VALUES INC SPACES+Z00123:D COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+000001+AAAAAAA+ANYVALUES+A'
000001 STRING OF TEXT1
000001 STRING OF TEXT2
000001 STRING OF TEXT3
END=3'
LMN=FED:1+EDRE:COULD SAY ANYTHING INCLUDING SPACES+FERD:COULD SAY ANSPACES+DDMMYYYY:HHMMSS+999999+AAAAAAA+ANYVALUES+A'
999999 STRING OF TEXT1
END=1'
LMN=XYZ:5+BZER:ANYTHING+B456:OTHE TEXT+DDMMYYYY:HHMMSS+801207+JHYTHGH+JUHY01+T'
801207 STRING OF TEXT1
801207 STRING OF TEXT2
801207 STRING OF TEXT3
801207 STRING OF TEXT4
801207 STRING OF TEXT5
801207 STRING OF TEXT6
801207 STRING OF TEXT7
801207 STRING OF TEXT8
END=8'

Re: Dos script to edit a variable text file

Posted: 25 Feb 2011 13:27
by aGerman
This would work for your example text:

Code: Select all

@echo off &setlocal

set "source=abc.txt"
set "dest=xyz.txt"
set "alpha=LMN"


>"%dest%" type nul

for /f "delims=1234567890 tokens=*" %%a in ('type "%source%"^|findstr /n "^"') do (
  set "line=%%a"
  call :proc
)
goto :eof

:proc
setlocal enabledelayedexpansion
(
  if "!line:~1,4!"=="%alpha%=" (
    for /f "delims=+ tokens=5" %%a in ("!line!") do set "pre=%%a"
    echo(!line:~1!
  ) else (
    if "!line:~1,4!"=="END=" (
      echo(!line:~1!
    ) else (
      echo(!pre! !line:~1!
    )
  )
)>>"%dest%"
endlocal&set "pre=%pre%"
goto :eof


Regards
aGerman

Re: Dos script to edit a variable text file

Posted: 25 Feb 2011 14:59
by kr1
aGerman many thanks for your help, this works great.

I've been trying various things to do this but without any success.
Thanks again.

Also if after doing this I want to strip out (delete) all lines starting "LNM" and "END" could this also be done?

possibly all in one so that in the resulting file "xyz" the data ends as below?

123456 STRING OF TEXT1
123456 STRING OF TEXT2
123456 STRING OF TEXT3
123456 STRING OF TEXT4
123456 STRING OF TEXT5
000001 STRING OF TEXT1
000001 STRING OF TEXT2
000001 STRING OF TEXT3
999999 STRING OF TEXT1
801207 STRING OF TEXT1
801207 STRING OF TEXT2
801207 STRING OF TEXT3
801207 STRING OF TEXT4
801207 STRING OF TEXT5
801207 STRING OF TEXT6
801207 STRING OF TEXT7
801207 STRING OF TEXT8

Re: Dos script to edit a variable text file

Posted: 25 Feb 2011 16:08
by aGerman
untested:

Code: Select all

@echo off &setlocal

set "source=abc.txt"
set "dest=xyz.txt"
set "alpha=LMN"


>"%dest%" type nul

for /f "delims=1234567890 tokens=*" %%a in ('type "%source%"^|findstr /n "^"') do (
  set "line=%%a"
  call :proc
)
goto :eof

:proc
setlocal enabledelayedexpansion
(
  if "!line:~1,4!"=="%alpha%=" (
    for /f "delims=+ tokens=5" %%a in ("!line!") do set "pre=%%a"
  ) else (
    if "!line:~1,4!" neq "END=" (
      echo(!pre! !line:~1!
    )
  )
)>>"%dest%"
endlocal&set "pre=%pre%"
goto :eof

Regards
aGerman

Re: Dos script to edit a variable text file

Posted: 25 Feb 2011 18:25
by kr1
aGerman,

Thanks again, that one was also spot on.

I tested that it produced the same results in the data as when I manually remove the other lines and the two files were identical when compared.

Your help is greatly appreciated.

Cheers

Re: Dos script to edit a variable text file

Posted: 26 Feb 2011 02:33
by kr1
aGerman,

Once again thanks for your advice. I hope I'm not asking too much.
I can now use Textpad to edit the data further into a format that I need. However, this is quite a lengthy
process which I need to complete daily.

Could this be fully completed using a .bat file?

I have re-iterated the original requirements which you were a great help with, but now want to try and extend that to
do the complete process if possible.Sorry there's a to come from the LMN line that I forgot about,
plus the additional requirements.

I have including various iterations of the same data, in order to try and explain my requirement clearly.

Hope you can help, and thank you once again.

//Requirement

Take Data from the preceeding row (starting LNM=) and also data from its own row, removing any other text.

Data from preceeding row is as previous;
Text from between the 4th & 5th + sign
but also
Text after the 2nd + sign & the next :

Text required from its own row;
1 Text after the + sign that comes after the CID= (or this is the 2nd + sign on the row)
2 Text before the 1st + sign
3 Text immediately following "PLH=" up to the next + sign

Removing the lines for
LNM
END

Removing any additional text that isn't Required


// Eg. Starting Data

LMN=ABC:1+BBBB:COULD SAY AN+ZSED:COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+123456+AAAAAAA+ANYVALUES+A'
MHD=1+HGYT00:5'CID=C00222:DSKJDISDWS+F03276: 'PLH=27TD90H00585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=2+JHYT88:1'CID=PZ0278:SDIDIWUDIJWI+Z03230: 'PLH=7878790GY000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=3+RNJH77:6'CID=VG0278:WSDWI+W03630: 'PLH=2644DZM00UY5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=4+JHYU56:5'CID=PY0278:99d9wd9i+3403200: 'PLH=27T6R479M089585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=5+GHYT67:1'CID=KJ0278:CDCKOK+YT3870: 'PLH=274HN0C097585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=5'
LMN=ABC:1+C00016:DIFFERENT VALUES INC SPACES+Z00123:D COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+000001+AAAAAAA+ANYVALUES+A'
MHD=1+ABCD99:1'CID=XXXXXX:JUYIOD+T08884: 'PLH=9999999J787181+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=2+DFCD99:1'CID=XNNNNN:ASJFGwsdWF+YTYHTRD: 'PLH=76YWE5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=3+FCFD99:1'CID=CRTYU8:SDKJSD+EREFEEF: 'PLH=279849MG000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=3'
LMN=FED:1+EDRE:COULD SAY ANYTHING INCLUDING SPACES+FERD:COULD SAY ANSPACES+DDMMYYYY:HHMMSS+999999+AAAAAAA+ANYVALUES+A'
MHD=1+HHHH01:1'CID=J7676:KJIU+A12345: 'STY=AAA:HHH:000001:01062003:01062003'SFT=1'PLH=8928777KM000104+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=1'
LMN=XYZ:5+BZER:ANYTHING+B456:OTHE TEXT+DDMMYYYY:HHMMSS+801207+JHYTHGH+JUHY01+T'
MHD=1+ABCD99:1'CID=XXXXXX:JUYIOD+A08884: 'PLH=9999999J787181+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=2+ABCD99:1'CID=XNNNNN:ASJFGwsdWF+LMNOPQ: 'PLH=76YWE5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=3+ABCD99:1'CID=CRTYU8:SDKJSD+S89999: 'PLH=279849MG000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=4+HGYT00:5'CID=C00222:DSKJDISDWS+F03276: 'PLH=27TE90MyH00585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=5+JHYT88:1'CID=PZ0278:SDIDIWUDIJWI+C03230: 'PLH=7447790GT000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=6+RNJH77:6'CID=VG0278:WSDWI+Q03630: 'PLH=274479ZM00UY5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=7+JHYU56:5'CID=PY0278:99d9wd9i+T03200: 'PLH=27TR479M089585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
MHD=8+GHYT67:1'CID=KJ0278:CDCKOK+A03870: 'PLH=274HN0C099585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=8'

// Picks up the relevant data

LMN=ABC:1+BBBB:COULD SAY AN+ZSEDEFRIERT:COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+123456+AAAAAAA+ANYVALUES+A'
123456|ZSEDEFRIERT|F03276|MHD=1|27TD90H00585 MHD=1+HGYT00:5'CID=C00222:DSKJDISDWS+F03276: 'PLH=27TD90H00585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
123456|ZSEDEFRIERT|Z03230|MHD=2|7878790GY000585 MHD=2+JHYT88:1'CID=PZ0278:SDIDIWUDIJWI+Z03230: 'PLH=7878790GY000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
123456|ZSEDEFRIERT|W03630|MHD=3|2644DZM00UY5 MHD=3+RNJH77:6'CID=VG0278:WSDWI+W03630: 'PLH=2644DZM00UY5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
123456|ZSEDEFRIERT|3403200|MHD=4|27T6R479M089585 MHD=4+JHYU56:5'CID=PY0278:99d9wd9i+3403200: 'PLH=27T6R479M089585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
123456|ZSEDEFRIERT|YT3870|MHD=5|274HN0C097585 MHD=5+GHYT67:1'CID=KJ0278:CDCKOK+YT3870: 'PLH=274HN0C097585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=5'
LMN=ABC:1+C00016:DIFFERENT VALUES INC SPACES+Z00123:D COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+000001+AAAAAAA+ANYVALUES+A'
000001|Z00123|T08884|MHD=1|9999999J787181 MHD=1+ABCD99:1'CID=XXXXXX:JUYIOD+T08884: 'PLH=9999999J787181+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
000001|Z00123|YTYHTRD|MHD=2|76YWE5 MHD=2+DFCD99:1'CID=XNNNNN:ASJFGwsdWF+YTYHTRD: 'PLH=76YWE5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
000001|Z00123|EREFEEF|MHD=3|279849MG000585 MHD=3+FCFD99:1'CID=CRTYU8:SDKJSD+EREFEEF: 'PLH=279849MG000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=3'
LMN=FED:1+EDRE:COULD SAY ANYTHING INCLUDING SPACES+FERD:COULD SAY ANSPACES+DDMMYYYY:HHMMSS+999999+AAAAAAA+ANYVALUES+A'
999999|FERD|A12345|MHD=1|8928777KM000104 MHD=1+HHHH01:1'CID=J7676:KJIU+A12345: 'STY=AAA:HHH:000001:01062003:01062003'SFT=1'PLH=8928777KM000104+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=1'
LMN=XYZ:5+BZER:ANYTHING+B456:OTHE TEXT+DDMMYYYY:HHMMSS+801207+JHYTHGH+JUHY01+T'
801207|B456|A08884|MHD=1|9999999J787181 MHD=1+ABCD99:1'CID=XXXXXX:JUYIOD+A08884: 'PLH=9999999J787181+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
801207|B456|LMNOPQ|MHD=2|76YWE5 MHD=2+ABCD99:1'CID=XNNNNN:ASJFGwsdWF+LMNOPQ: 'PLH=76YWE5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
801207|B456|S89999|MHD=3|279849MG000585 MHD=3+ABCD99:1'CID=CRTYU8:SDKJSD+S89999: 'PLH=279849MG000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
801207|B456|F03276|MHD=4|27TE90MyH00585 MHD=4+HGYT00:5'CID=C00222:DSKJDISDWS+F03276: 'PLH=27TE90MyH00585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
801207|B456|C03230|MHD=5|7447790GT000585 MHD=5+JHYT88:1'CID=PZ0278:SDIDIWUDIJWI+C03230: 'PLH=7447790GT000585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
801207|B456|Q03630|MHD=6|274479ZM00UY5 MHD=6+RNJH77:6'CID=VG0278:WSDWI+Q03630: 'PLH=274479ZM00UY5+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
801207|B456|T03200|MHD=7|27TR479M089585 MHD=7+JHYU56:5'CID=PY0278:99d9wd9i+T03200: 'PLH=27TR479M089585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
801207|B456|A03870|MHD=8|274HN0C099585 MHD=8+GHYT67:1'CID=KJ0278:CDCKOK+A03870: 'PLH=274HN0C099585+STRING CONTINUES WITH VARIOUS "+" SIGNS : SIGNS AND TEXT BUT NOT NEEDED
END=8'


// With values required but header & footer in

LMN=ABC:1+BBBB:COULD SAY AN+ZSEDEFRIERT:COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+123456+AAAAAAA+ANYVALUES+A'
123456|ZSEDEFRIERT|F03276|MHD=1|27TD90H00585
123456|ZSEDEFRIERT|Z03230|MHD=2|7878790GY000585
123456|ZSEDEFRIERT|W03630|MHD=3|2644DZM00UY5
123456|ZSEDEFRIERT|3403200|MHD=4|27T6R479M089585
123456|ZSEDEFRIERT|YT3870|MHD=5|274HN0C097585
END=5'


LMN=ABC:1+C00016:DIFFERENT VALUES INC SPACES+Z00123:D COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+000001+AAAAAAA+ANYVALUES+A'
000001|Z00123|T08884|MHD=1|9999999J787181
000001|Z00123|YTYHTRD|MHD=2|76YWE5
000001|Z00123|EREFEEF|MHD=3|279849MG000585
END=3'


LMN=FED:1+EDRE:COULD SAY ANYTHING INCLUDING SPACES+FERD:COULD SAY ANSPACES+DDMMYYYY:HHMMSS+999999+AAAAAAA+ANYVALUES+A'
999999|FERD|A12345|MHD=1|8928777KM000104
END=1'

LMN=XYZ:5+BZER:ANYTHING+B456:OTHE TEXT+DDMMYYYY:HHMMSS+801207+JHYTHGH+JUHY01+T'
801207|B456|A08884|MHD=1|9999999J787181
801207|B456|LMNOPQ|MHD=2|76YWE5
801207|B456|S89999|MHD=3|279849MG000585
801207|B456|F03276|MHD=4|27TE90MyH00585
801207|B456|C03230|MHD=5|7447790GT000585
801207|B456|Q03630|MHD=6|274479ZM00UY5
801207|B456|T03200|MHD=7|27TR479M089585
801207|B456|A03870|MHD=8|274HN0C099585
END=8'



// Final Requirements in File in "xyz"

123456|ZSEDEFRIERT|F03276|MHD=1|27TD90H00585
123456|ZSEDEFRIERT|Z03230|MHD=2|7878790GY000585
123456|ZSEDEFRIERT|W03630|MHD=3|2644DZM00UY5
123456|ZSEDEFRIERT|3403200|MHD=4|27T6R479M089585
123456|ZSEDEFRIERT|YT3870|MHD=5|274HN0C097585
000001|Z00123|T08884|MHD=1|9999999J787181
000001|Z00123|YTYHTRD|MHD=2|76YWE5
000001|Z00123|EREFEEF|MHD=3|279849MG000585
999999|FERD|A12345|MHD=1|8928777KM000104
801207|B456|A08884|MHD=1|9999999J787181
801207|B456|LMNOPQ|MHD=2|76YWE5
801207|B456|S89999|MHD=3|279849MG000585
801207|B456|F03276|MHD=4|27TE90MyH00585
801207|B456|C03230|MHD=5|7447790GT000585
801207|B456|Q03630|MHD=6|274479ZM00UY5
801207|B456|T03200|MHD=7|27TR479M089585
801207|B456|A03870|MHD=8|274HN0C099585

Re: Dos script to edit a variable text file

Posted: 27 Feb 2011 08:17
by aGerman
Hmm, there is no ZSEDEFRIERT in your source file (found only ZSED). I was unable to find 8928777KM000104 but found AAA instead. So I hope the code will work for you :|

Code: Select all

@echo off &setlocal

set "source=abc.txt"
set "dest=xyz.txt"
set "alpha=LMN"


>"%dest%" type nul

for /f "delims=1234567890 tokens=*" %%a in ('type "%source%"^|findstr /n "^"') do (
  set "line=%%a"
  call :proc
)
goto :eof

:proc
setlocal enabledelayedexpansion
if "!line:~1,4!"=="%alpha%=" (
  for /f "delims=+ tokens=3,5" %%a in ("!line!") do (
    set "pre=%%b"
    for /f "delims=:" %%c in ("%%a") do set "second=%%c"
  )
) else (
  if "!line:~1,4!" neq "END=" (
    for /f "tokens=1,3 delims=+" %%a in ("!line:~1!") do (
      for /f "tokens=1,3 delims=:=" %%c in ("%%b") do (
        >>"%dest%" echo(!pre!^|!second!^|%%c^|%%a^|%%d
      )
    )
  )
)
endlocal&set "pre=%pre%"&set "second=%second%"
goto :eof


Think the reason why I didn't find 8928777KM000104 I that there is not the same number of + signs in the line. Is there a way to equalize your source file?

Regards
aGerman

Re: Dos script to edit a variable text file

Posted: 27 Feb 2011 15:07
by kr1
aGerman,

Thanks once again for your help
I believe that there are the same amount of + signs in all of the rows of data, including the line with 8928777KM000104 in it.

There are however, a different amount of colons ":" and also = signs. This cannot be equalised.

Is there any way that the "PLH=" and the plus "+" sign could be used to pick up the value in between them as the PLH= followed by the plus are constants?

Kind Regards
Karl

Re: Dos script to edit a variable text file

Posted: 27 Feb 2011 15:35
by aGerman
It becomes more and more complicated :?
Try this:

Code: Select all

@echo off &setlocal

set "source=abc.txt"
set "dest=xyz.txt"
set "alpha=LMN"


>"%dest%" type nul

for /f "delims=1234567890 tokens=*" %%a in ('type "%source%"^|findstr /n "^"') do (
  set "line=%%a"
  call :proc
)
goto :eof

:proc
setlocal enabledelayedexpansion
if "!line:~1,4!"=="%alpha%=" (
  for /f "delims=+ tokens=3,5" %%a in ("!line!") do (
    set "pre=%%b"
    for /f "delims=:" %%c in ("%%a") do set "second=%%c"
  )
) else (
  if "!line:~1,4!" neq "END=" (
    for /f "tokens=1,3 delims=+" %%a in ("!line:~1!") do (
      for /f "delims=:" %%c in ("%%b") do (
        set "part=%%b"
        for /f "tokens=2 delims=;" %%d in ("!part:'PLH=;!") do (
          set "part2=%%d"
          >>"%dest%" echo(!pre!^|!second!^|%%c^|%%a^|!part2:~1!
        )
      )
    )
  )
)
endlocal&set "pre=%pre%"&set "second=%second%"
goto :eof


Regards
aGerman

Re: Dos script to edit a variable text file

Posted: 27 Feb 2011 15:58
by kr1
Your a Genius.

Result!!

This will save me so much time every day.

Thanks a million.
:D :D