Skip lines inside nested for loop
Posted: 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
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