how to delete last record in a text file usin

August 16, 2011 at 05:41:32
Specs: Windows XP
how to delete last record in a text file using batch script?

See More: how to delete last record in a text file usin

Report •

#1
August 18, 2011 at 01:24:18
Test this:

@echo off
cls

setlocal 

for /f "tokens=*" %%1 in (inputfile) do (
    set lastline=%%1
)

for /f "tokens=*" %%2 in (inputfile) do (
    if "%%2" neq "!lastline!" echo %%2>>outputfile
  
)


Please come back & tell us if your problem is resolved.


Report •

#2
August 18, 2011 at 01:44:48
Hi Wahine

I have tried this and it is not working..I have given the text file name where you have mentioned as Input File, let me know if that is what should be given in the place of Input File.

Thanks


Report •

#3
August 18, 2011 at 14:36:16
Oops, sorry, must have had a blonde moment.

Please add enabledelayedexpansion to setlocal so that the command line reads setlocal enabledelayedexpansion

That should solve the problem.

W.


Please come back & tell us if your problem is resolved.


Report •
Related Solutions


Ask Question