Ops! You are right!
This is the fixed code:
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set ^"LF=^
%empty line%
^"
set /A "lastOffset=0, i=0"
for /F "delims=:" %%a in ('findstr /O "^" test.txt') do (
set /A "len[!i!]=%%a-lastOffset-2, lastOffset=%%a, i+=1"
)
for %%a in (test.txt) do set /A "len[%i%]=%%~Za-lastOffset-1"
set "i=0"
set "inBody="
>"T1.txt" <NUL (for /F "delims=" %%a in (test.txt) do (
set "line=%%a"
set /A i+=1
set /A "len=len[!i!]"
for %%i in (!len!) do set "endsInLF=!line:~%%i!"
if not defined inBody (
for /F "tokens=1-3 delims=;" %%i in ("%%a") do (
echo BEGIN:VMESSAGE
echo TYP:SMS;IN
echo BOX:INBOX
echo READ:0
echo DATE:%%j
echo NUMBER:%%i
if not defined endsInLF (
echo BODY;CHARSET=1253:%%k
echo END:VMESSAGE
) else (
set /P "=BODY;CHARSET=1253:%%k!LF!"
set "inBody=1"
)
)
) else (
if defined endsInLF (
set /P "=%%a!LF!"
) else (
echo %%a
echo END:VMESSAGE
set "inBody="
)
)
))