Syntax for writing a loop inside a batch file
I am trying to write a small batch file for a task that I do regularly. I have never used it before for
and this is the first time I try this. This is what I ended up with:
for /f %i in ('ct find . -ver lbtype(%1) -print') do ct lsvt -g %i
Basically it tries to find all files with the specified cleracase tag and then display the version tree of those files. The problem is %1
. But when I try to run this sometime it gives me an error saying -print )
not expected or ever else it just prints this command on the command line. I guess this is confusing between several paradelts. Any hints how I solve this?
a source to share
Try to specify the command you are running in for
:
for /f %i in ('"ct find . -ver lbtype(%1) -print"') do ct lsvt -g %i
This worked for the same command as mine, with arguments with parens.
Also, as you probably know, you need to double characters '%'
for the variable for
if you put the command in a batch file instead of running it on the command line:
for /f %%i in ('"ct find . -ver lbtype(%1) -print"') do ct lsvt -g %%i
a source to share