<
andrewn...@gmail.com> wrote in message
news:32397669.213.1331600958939.JavaMail.geo-discussion-forums@pbnt10...
Well, it would probably be better to produce the prefix within your
unpublished batch.
Assuming that you are using W2000 or later, and the output file that you
have produced is say, babinda.txt then
@echo off
del babinda.cnv 2>nul
(set before=Open Table )
for /f "delims=" %%i in (babinda.txt) do (
call :decide %%i
if defined prefix (>>babinda.cnv echo %before% %%i
) else (
>>babinda.cnv echo %%i)
)
goto :eof
:decide
set prefix=%1
set prefix=%prefix:~1,1%
if not "%prefix%"==":" (set prefix=)
goto :eof
would process babinda.txt to babinda.cnv BUT would eliminate all of the
empty lines
and
@echo off
del wungu.cnv 2>nul
(set before=Open Table )
for /f "tokens=1,2delims=]" %%h in ( ' find /n /v "" ^<babinda.txt ' ) do (
call :decide %%i
if defined prefix (>>wungu.cnv echo %before% %%i
) else (
(set prefix=%%i)
if defined prefix (>>wungu.cnv echo %%i) else (
>>wungu.cnv echo.
)
)
)
goto :eof
:decide
set prefix=%1
set prefix=%prefix:~1,1%
if not "%prefix%"==":" (set prefix=)
goto :eof
would process babinda.txt to wungu.cnv and would preserve the empty lines.
Note that these techniques may be a little sensitive to some symbols like
"%" in particular. More information or diligent testing required...
Notes :
the 'del filename 2>nul' construct deletes the file if possible and
suppresses error messages
the (set ...) construct allows spaces to be safely added as terminal
characters without fear of having the editor being too helpful and deleting
them.
Note that the metavariable (loop-control variable) in wungu is h and babinda
is i (and is case-sensitive)
the ^<filename in the FIND substatement is to escape the redirection
character so that the FIND acts as though the file is typed in from the
keyboard
The spaces around the single-quotes enclosing the FIND substatement are for
emphasis. The single-quotes are required, but the spaces are optional.
The sequence ") else (" where used must have the close-parenthesis before
and the open-parenthesis after the else ON THE SAME PHYSICAL LINE.
the :eof label is DEFINED by the command-processor as PHYSICAL END-OF-FILE
and should not be defined by the programmer.
The :decide procedure
1) sets 'prefix' to the value of the first parameter supplied to the
procedure (not the first supplied to the batch itself) Then isolates the
SECOND character (at position 1 in the string (starting at character "0")
get 1 character) of the string; then sets PREFIX to nothing if that
character is not a colon.
==> consequently, PREFIX will be either a colon or not-defined on return.
All of these techniques are documented (if poorly) - use
for /?
from the prompt for help.
OR you could try the etensive discussion over the past few years in
alt.msdos.batch.nt where there is extensive information about "poison
characters" (the set of characters that batch may have problems processing)
and ways to get around them and other traps discovered over the years...