Windows 批处理文件迭代器问题
我有 3 个使用 svn 的项目。我的文件夹系统是:有一个文件夹projects
,在projects文件夹中有3个项目projectA
、projectB
和projectC.
我有一个像这样的 Windows 批处理脚本代码:
d:
cd projectA
svn update
cd ../projectB
svn update
cd ../projectC
svn update
它的目的是使用一个 .bat 文件我想更新我的所有项目。该代码似乎可以改进。是否可以将其更改为:
set folder=projects
set directories=(projectA projectB projectC)
set command=svn update
d:
for %%i in %directories% do cd.. && cd %folder%/%%i && %command%
该代码在某处失败。应该将其更改为 do while 循环或类似的东西,因为它尝试在项目文件夹下创建 cd items\projectB
(它应该在项目的上层文件夹中执行 cd items\etc。 )
编辑: @Andriy M 有我电脑的屏幕截图。红色是项目A,蓝色是项目B,紫色是项目C。
在这里:
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 with 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:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是什么阻止你像这样实现它:
?
What prevents you from implementing it like this:
?