nesting for loop

Microsoft Windows small business server...
March 30, 2010 at 02:56:44
Specs: Windows XP, 2GB
Hi Folks ...

I am facing an issue while nesting the for loops
in windows ..

FOR /F "usebackq delims=;" %Q IN (`dir /B `)
DO (for /f "usebackq delims=;" %R IN (` cvs
status -- %Q ^| findstr "Repository" `)DO set
%S =` type -- %Q ^| findstr /I "VERSION:" `
DO Echo %Q, %R, %S >> b1.txt )

I have my files under a particular directory
now I wish to get the file name, the relative
path of the file, CVS version
of the file and internal version of the file .. in
the same line of output in the text file b1.txt

the above code when run seperately :

ie : FOR /F "usebackq delims=;" %Q IN (`dir
/B `) DO (for /f "usebackq delims=;" %R IN (`
cvs status -- %Q ^| findstr "Repository" `) DO
Echo %Q, %R >> b1.txt)

and : FOR /F "usebackq delims=;" %P IN (`dir
/B `) DO (for /f "usebackq delims=;" %S IN (`
type -- %P ^| findstr /I "VERSION:" `) DO Echo
%P, %S >> b5.txt)

works fine .. but when I try to nest the for
loops the issue occurs ..

and the issue too is a rather strange 1 .. the
code runs .. but there is no output in the file ..


another attempt which I gave was :

FOR /F "usebackq delims=;" %Q IN (`dir /B `)
DO (for /f "usebackq delims=;" %R IN (` cvs
status -- %Q ^| findstr "Repository" `) DO (For
/F "usebackq delims=" %S in (`Echo %Q,
%R`) Do Set MyVar1=%S
For /F "usebackq delims= %T in (`findstr /I
"\<VERSION\>" %Q`) Do Set MyVar2=%T
Echo [%MyVar1%] [%MyVar2%] >> b3.txt ..

But this too without success ..

Pls see if u can help me out with the code ..
thanks


See More: nesting for loop

Report •

#1
March 30, 2010 at 04:20:52
Probably a missing quote somewhere ... I would try to write this code in a readable manner, which would mean using functions.

Report •

#2
March 30, 2010 at 05:01:43
Yeah, I don't know what it looked like when first written, but it's mangled now.


=====================================
Helping others achieve escape felicity

M2


Report •

#3
March 30, 2010 at 08:24:24
FOR /F "usebackq delims=;" %%Q IN (`dir /B `) DO (
for /f "usebackq delims=;" %%R IN (` cvs status -- %%Q ^| findstr "Repository" `)DO (
for /f "tokens=*" %%S in (` type %%Q ^| findstr /I "VERSION:" `) do (
Echo %%Q, %%R, %%S >> b1.txt
)
)
)
::---------
might give it a shot...
if you could post the output of what i'm assuming is a command: "CVS STATUS -- filename", that would help.
also, it don't know what this is doing:
type -- %Q
getting the %s variable, so i took out the dashes.
somehow, it seems there must be an easier path to destruction...
i understand the "for loop"s are required to capture output to variables, (which is unfortunately the only way as far as i know), so it makes things kind of messy.

Report •
Related Solutions


Ask Question