(If the last char is not a ^M then add ^M.)
Thanks for any help.
Why bother with the testing? Just always type (with for) the file
redirecting it to another file.
@echo off
if exist whatever2 del whatever2
for /f "tokens=*" %%a in (whatever) do echo %%a >>whatever2
if exist whatever if exist whatever2 del whatever
ren whatever2 whatever
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm
more filename>newfilename
should append ^J if missing from last line
I wouldn't bother with a test - I'd just
echo.>> logfile
If it were absolutely essential to avoid an extra blank line at the end,
I'd:
awk "{print $0}" logfile > newfile
where awk is gawk.exe from
<http://gnuwin32.sourceforge.net/packages/gawk.htm>
If were essential to avoid creating an intermediate file, I'd:
awk "{A[NR]=$0}END{y=FILENAME;close(FILENAME);for(x=1;x<=NR;x++)print
A[x]>y}"
Not tested - typos are likely.
--
T.E.D. (tda...@mst.edu) MST (Missouri University of Science and Technology)
used to be UMR (University of Missouri - Rolla).
Thank you all. Not only did all your samples work but you gave me a
better way to think about the problem. Much appreciated!
This tests the last character and adds a CRLF only if the last character is
not a LF.
@echo off
echo> $.vbs filespec = "test.txt"
echo>>$.vbs Set fso = CreateObject("Scripting.FileSystemObject")
echo>>$.vbs fs = fso.GetFile(filespec).Size
echo>>$.vbs Set f = fso.OpenTextFile(filespec,1)
echo>>$.vbs f.Skip(fs-1)
echo>>$.vbs If Not f.Read(1) = Chr(10) Then
echo>>$.vbs Set f = fso.OpenTextFile(filespec,8)
echo>>$.vbs f.Write vbCRLF
echo>>$.vbs End If
cscript /nologo $.vbs
del $.vbs
--
Todd Vargo (remove hyphen to reply by email)
Never trust anyone who polices newsgroups hypocritically or supports
knowingly providing misinformation.
Thanks.