开发者

Windows Batch File Iterator Problem

I have 3 projects that I use svn for them. My folder system is that: There is a folder projects, within projects folder there are 3 projects projectA, projectB and projectC.

I have a Windows batch script code like that:

d:
cd projectA
svn update
cd ../projectB
svn update
cd ../projectC
svn update

The purpose of it w开发者_StackOverflowith one .bat file I want to update all of my projects. That code seems like can be improved. Is it possible to change it like:

set folder=projects
set directories=(projectA projectB projectC)
set command=svn update
d:
for %%i in %directories% do cd.. && cd %folder%/%%i && %command%

That code fails on somewhere. It should be change to do while loop or something like that because it tries to make cd projects\projectB while it is under projects folder (It should be at upper folder of projects to execute cd projects\etc.)

EDIT: @Andriy M There is a screenshot from my computer. Red is projectA, blue is projectB and purple is projectC.

Here it:

Windows Batch File Iterator Problem


What prevents you from implementing it like this:

SET folder=D:\fullpath\project
SET directories=(projectA projectB projectC)
SET command=svn update
FOR %%i IN %directories% DO (CD /D %folder%\%%i && %command%)

?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜