Skip lines inside nested for loop

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rkp1
Posts: 1
Joined: 01 Jul 2011 17:53

Skip lines inside nested for loop

#1 Post by rkp1 » 01 Jul 2011 18:04

I am trying do the following -

I have to parse multiple files (numbers can vary from 1 to 50+), and in each file, I need to find a segment of lines that start with a specific entry and process all lines below that entry. The number of lines above that varies (anywhere from a 50 to 50000 lines). Here is what I tried -

@echo off

setLocal EnableDelayedExpansion

for /F %%A in (%file_list%) do (
SET file_name=%%A

:: -----Check if file is missing-----
if not exist !file_name! (
SET SuccessFlg=P
goto End
)

:: ----Check for Statistics----
for /F "tokens=1,* delims=:" %%A in ('find /c "Summary" !file_name!') do SET var1=%%B
if !var1! equ 0 goto End

for /F "tokens=1,* delims=[]," %%i in ('find /n "Summary" !file_name!') do SET LineNoSrc=%%i

for /F "skip=%LineNoSrc% tokens=1-13* delims=[],:()> " %%a in (!file_name!) do (
some commands)

goto End
)
:End
@echo on

I tried both %LineNoSrc% as well as !LineNoSrc!. Neither of them seem to work.

How do I fix this?

Thanks

Acy Forsythe
Posts: 126
Joined: 10 Jun 2011 10:30

Re: Skip lines inside nested for loop

#2 Post by Acy Forsythe » 02 Jul 2011 08:36

Try this:

viewtopic.php?f=3&t=1989

Just remove the exit/b in the forloop. And if you want to stop searching the file when you are done parsing the bottom lines, put the exit/b inside the top loop.

You're on the right track though...

Post Reply