Hi. I have a batch file to remove the last line of my .txt file. In this case it copies all rows (except the last one) from d177920101id.txt
and into docinfo.txt
It copies the lines great, but each line is cut off at the first space.
So in d177920101id.txt I have the lines
BIG|CONSTRUCTION|INC
HANSEN|TOWING AND REPAIR|INC
EOF 2
In docinfo.txt I end up with
BIG|CONSTRUCTION|INC
HANSEN|TOWING
Any idea how I can change my batch file to copy the entire lines including the spaces?
and into docinfo.txt
It copies the lines great, but each line is cut off at the first space.
So in d177920101id.txt I have the lines
BIG|CONSTRUCTION|INC
HANSEN|TOWING AND REPAIR|INC
EOF 2
In docinfo.txt I end up with
BIG|CONSTRUCTION|INC
HANSEN|TOWING
Any idea how I can change my batch file to copy the entire lines including the spaces?
Code:
SETLOCAL ENABLEDELAYEDEXPANSION
rem Count the lines in file
set /a count=-1
for /F %%a in (d177920101id.txt) DO set /a count=!count!+1
rem Create empty temp file
copy /y NUL tempfile.txt >NUL
rem Copy all but last line
for /F %%a in (d177920101id.txt) DO (
IF /I !count! GTR 0 (
echo %%a >> tempfile.txt
set /a count=!count!-1
)
)
rem overwrite original file, delete temp file
copy /y tempfile.txt docinfo.txt >NUL
del tempfile.txt