Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch remove line after searchstrin
Name: Morphin Date: July 18, 2008 at 07:02:08 Pacific OS: Div CPU/Ram: Div Product: Div
Comment:
Hi I would like to delete the next line (not empty) in a file following a search string. I can find the line with the string with "FOR /F", but i need to delete the next line of this file.
Name: Mechanix2Go Date: July 19, 2008 at 13:29:37 Pacific
Reply:
"OS: Div"
Help me out here.
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: Morphin Date: July 20, 2008 at 22:34:48 Pacific
Reply:
Hi
Sorry i don't unterstand. What's the meaning of "OS: DIV"? Regards Andy
Andy
0
Response Number 3
Name: Mechanix2Go Date: July 21, 2008 at 03:18:30 Pacific
Reply:
In order to write a batch, one would need to know the OS.
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 4
Name: Morphin Date: July 21, 2008 at 03:24:39 Pacific
Reply:
Oh Sorry, Windows 2003 Server, I thought that i wrote this on my preferences. -> DOS BATCH
Andy
Andy
0
Response Number 5
Name: Mechanix2Go Date: July 21, 2008 at 05:30:00 Pacific
Reply:
@echo off > newfile setLocal EnableDelayedExpansion
for /f "tokens=1 delims=[] " %%a in ('find /n "string" ^< myfile') do ( set /a N=%%a+1 ) for /f "tokens=1* delims=[] " %%a in ('find /n /v "" ^< myfile') do ( if not %%a equ !N! echo %%b >> newfile )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 6
Name: Morphin Date: July 24, 2008 at 04:29:52 Pacific
Reply:
Hi
Thank's very much. You are wonderful! Regards Andy
Andy
0
Response Number 7
Name: Morphin Date: July 25, 2008 at 01:13:22 Pacific
Reply:
Hi I had to change your script a little bit. 1) i also want to remove the line with the string that i searched and 2) the file has lines with "[sometext]" inside. So i had change "find" to "findstr" -------------------- SET OutFile=sidtest.conf SET Identifier=ictr1t
for /f "tokens=1 delims=:" %%a in ('findstr /n "%Identifier%" ^< sid.conf') do ( set /a N=%%a+1 )
for /f "tokens=1* delims=:" %%a in ('findstr /n /v %Identifier% ^< sid.conf') do ( if not %%a equ !N! echo %%b >> %OutFile% ) --------------------- Now i have the problem if it has "empty" lines in the file it will be replaced with "ECHO is off." ->how do i supress this? Thank you very much for your help Regards Andy
Andy
0
Response Number 8
Name: Morphin Date: July 25, 2008 at 01:38:57 Pacific
Reply:
Hi I have found the solution: echo/%%b will do the trick
Summary: Hi, I have a sample file First line 11111 anything second line anything third line anything fourth line 2222 anything fifth line anything sixth line anything seventh line 3333 anything eightth line an...
Summary: Hi all! In this batch file: :: multiIP.bat @echo on for /f "tokens=*" %%I in (c:\tmp\IPlist) do call :pinger %%I goto :eof :pinger ping -a %1 >> pingLOG :: DONE I would like to extract the...
Summary: Hello, I am trying to write a batch file that gets an ical file from a website using GET and writes that to an ics file. I want it to do that multiple times, but my batch file exits after it does it o...