Need to delete line in file

March 30, 2011 at 20:48:45
Specs: Windows Server
Dear Sir,

I need to create batch file to delete first line and last line of data in text file.
Could you please help me?

PS. The first line start "00" and last line start "99"
Simple data in text file is below

00|KB_P2P_REMEDY|FAPOOUT|01|554|20100709174023
01|15875|1403002D6068|Y|PRODUCT DESCRPIPTION|DELL|Optiplex GX745MT
01|15875|1403002D6069|Y|PRODUCT DESCRPIPTION|DELL|Optiplex GX745MT
01|15875|1403002D6069|Y|PRODUCT DESCRPIPTION|DELL|Optiplex GX745MT
.
.
.
.
01|15875|1403002D6069|Y|PRODUCT DESCRPIPTION|DELL|Optiplex GX745MT
99|KB_P2P_REMEDY|FAPOOUT|01|554|20100709174023|2

Best Regards,
Gunner


See More: Need to delete line in file

Report •


#1
March 31, 2011 at 02:37:45
:: ==========================================
::
:: gugu.bat Thu 31-03-2011 15:57:28.64
@echo off > newfile & setLocal enableDELAYedeXpansioN

set T=
for /f "tokens=* delims= " %%a in (myfile) do (
set /a T+=1
)

set N=
for /f "skip=1 tokens=* delims= " %%a in (myfile) do (
set /a N+=1
if !N! neq !T! ( >> newfile echo.%%a )
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
March 31, 2011 at 02:51:39
Here's a Ruby for Windows command

C:\work>ruby -0777 -ne "puts $_.split(/\n/)[1..-2].join(\"\n\")" file


Report •

#3
April 3, 2011 at 20:19:50
All,

Thank you very much for your help.

Best Regards,
Gunner


Report •

Related Solutions


Ask Question