Matthias said:
:
<snip>
Hello Phil,
I'm a bit curious, I always got rec:~0,-1 in the output.
Hi, Matthias,
Well, unlike my usual practice, I didn't actually *test* the suggested
code; I merely copied your example and made what I thought would be the
appropriate change.
The echo status on empty lines is also present. This worked (but not
with html files where the last char is a closing bracket ;-)
The original poster's "the text file" was not specific enough. Of course,
depending on what is actually in a particular file, one may have to make
certain modifications (for example, to write out blank lines, etc.) And
html files where the last character is a closing bracket might also pose
a problem. But in general, it is indeed *possible* to remove the last
character from a text file via a batch file; it's just that a batch file
might not be the most *practical* means of doing so, depending on what is
in the text file in question.
::StripLastChar.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
if not exist %1 goto :eof
for /f %%A in ('find /V /C "" ^<%1') do set lines=%%A
for /f "tokens=1,* delims=[]" %%A in ('find /V /N "" ^<%1') do (
if %%A LSS %lines% (
echo/%%B
) else (
set "rec=%%B"
call echo.%%rec:~0,-1%%
)
)
::StripLastChar.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::