HELP: FOR LOOP inside another

June 22, 2009 at 02:05:14
Specs: Windows XP
Hello,
I'm trying to do the following:

for /F "tokens=1-2 delims=;" %%a in ('findstr /i "<Caption" "temp"') do (
	set /a counter+=1
	set /a N+=1
	for /F "tokens=1-2 delims=;" %%e in ('findstr /i "text;" "temp"') do (
		set /a counter2+=1
		if "!counter2!"=="!counter!" (
		echo %%b %%e %%f
		goto :eoloop
		)
	)
:eoloop
) >>"temp2"

The problem is that when the program leaves the second "for loop" it was supposed to continue on the first "for loop". But is leaves it too. I think it's because of the goto command.
But since I don't know too much about batch I need help on this.

Thanks


See More: HELP: FOR LOOP inside another

Report •


#1
June 22, 2009 at 02:35:05
Yes, you can't code a goto that jumps to a location inside a For loop. Replace

for /F "tokens=1-2 delims=;" %%a in ('findstr /i "<Caption" "temp"') do (
  set /a counter+=1
  set /a N+=1
  for /F "tokens=1-2 delims=;" %%e in ('findstr /i "text;" "temp"') do (
  set /a counter2+=1
  if "!counter2!"=="!counter!" (
    echo %%b %%e %%f
    goto :eoloop
    )
  )
:eoloop
) >>"temp2"

  with

for /F "tokens=1-2 delims=;" %%a in ('findstr /i "<Caption" "temp"') do (
  set /a counter+=1
  set /a N+=1
  call :SUB %%b
)
.......
goto :EOF
:SUB
  for /F "tokens=1-2 delims=;" %%e in ('findstr /i "text;" "temp"') do (
  set /a counter2+=1
  if "!counter2!"=="!counter!" (
    echo %* %%e %%f >>"temp2"
    goto :EOF
    )
  )
goto :EOF


Report •

#2
June 22, 2009 at 08:19:39
Worked perfectly, THANKS!

But since temp file fas 2000 lines,I think this indead with loop inside another is taking to much to process. 2000 * 2000.

This is what I'm trying to do:

temp file format:
time 00:00:00:00
text;blablabla
time 00:00:03:29
text;blablablablblablbalblalba
time 00:00:5:11
...

I want to convert to this format:

00:00:00:00 --> 00:00:03:28
blablabla
00:00:03:29 --> 00:00:5:10
blablablablblablbalblalba
00:00:5:11 ..........

Basically if I could put time1 (time2 - 1ms) and text on the same line, I could do the rest.

Thanks


Report •

#3
June 22, 2009 at 12:23:01
The logic of your process is not clear to me, anyway to accomplish the transform you need is possible, but...

- the last number means 1/100 secs not msecs;
- how to handle 00:00:00:00?

I suppose e.g. 00:00:02:00 -> 00:00:01:99 interpreting the time (elapsed) as hh:mm:ss:ss/100.

More the lines' sequence must strictly follow

time/text/time/text... and so on.


Report •

Related Solutions


Ask Question