I've seen a "trick" to seperate the single characters of a file:
http://www.dostips.com/forum/viewtopic.php?f=3&t=5050.
But i have no experience, if that is really reliable: I think there are some poisonous character combinations, so you better check the result.
In addition the target file MUST have lines of limited length (don't know anymore where the limit is).
Then you could do something like this:
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
set "input=09_24_32_003_IN_RMS.txt"
set "output=09_24_32_003_Output.txt"
:: txar == -1 :<==> detect header
:: txar == 0 :<==> detected header is no TXAR line
:: txar == 1 :<==> detected header is a TXAR line
set "txar=-1"
set "header="
set "buffer="
>"%output%" (
for /F "tokens=1* delims=:" %%a in ('cmd /d /u /c type "%input%" ^| find /v "" ^| findstr /N "^"') do (
set "buffer=!buffer!%%~b"
if "%%~b" == "" (
if defined buffer (
if "!txar!" == "1" (
echo(!header!!buffer!
echo(
>&2 echo(warning unfinished entry: "!header!!buffer!"
) else (
rem no TXAR line: just buffered copy
echo(!buffer!
)
)
set "txar=-1"
set "header="
set "buffer="
) else if "!txar!" == "-1" (
rem header not fully read: autodetect header (TXAR line has 13 characters)
set "check=!buffer:~12!"
if defined check (
set "check=!buffer:~0,4!"
if "!check!" == "TXAR" (
set "header=!buffer!"
set "buffer="
set txar=1
)
)
) else if "!txar!" == "1" (
rem TXAR lines
set "check=!buffer:~98!"
if defined check (
echo(!header!!buffer:~0,99!
set "buffer=!buffer:~99!"
)
)
)
)
endlocal
If the "trick" above is not reliable, you have to dump the file to hex, maybe using:
http://www.dostips.com/forum/viewtopic.php?t=1786.
Then you have to do the same on the hex data, as above.
Finally you have to reconvert the hex data to binary data:
I'm sure i've seen a tool here on dostips which can do this, but i don't know it's name anymore - so i cannot provide a link.
penpen