开发者

Syntax for writing a loop inside the batch file

I am trying to write a small batch file for a task I do regularly. I have never used the for before and this is the first time I am trying this. This is what I have come with so far:

for /f %i in  ('ct find . -ver lbtype(%1) -print') do ct lsvt -g %i

Basically it tries find all the files with a given cleracase label and then display the version tree of those f开发者_运维技巧iles. The problem is in the %1 . But when I try to run this sometime it gives me an error saying that -print ) was not expected or sometime else it just prints this command on the command prompt. I guess it is getting confused between multiple paranthesis. Any clues how o I solve this?


Try quoting the command you're executing in the for:

for /f %i in  ('"ct find . -ver lbtype(%1) -print"') do ct lsvt -g %i

That worked for a similar command that I had that took args with parens.

Also, (as you're probably aware), you'll need to double-up on the '%' characters for the for variable when you put the command in a batch file instead of running it at the command line:

for /f %%i in  ('"ct find . -ver lbtype(%1) -print"') do ct lsvt -g %%i
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜