issues relating to dos scripting using for

  • rahul_nitc
  • Born
  • Born
  • rahul_nitc
  • Posts: 1

Post 3+ Months Ago

Hi Folks ...

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

Code: [ Select ]
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

Code: [ Select ]
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

Code: [ Select ]
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 :

Code: [ Select ]
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 ..
  1. 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
  2. For /F "usebackq delims= %T in (`findstr /I "\<VERSION\>" %Q`) Do Set MyVar2=%T
  3. Echo [%MyVar1%] [%MyVar2%] >> b3.txt ..


But this too without success ..

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

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 42 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.