2013-03-16 28 views
1

是否可以定义一个目录列表例如“DIR1”, “DIR2”,然后为每个目录的执行几个动作,例如:对于多线体的回路

  • xcopy C:\test\*.dll D:\%%le_dir%%\dll /Y

  • xcopy C:\test\*.exe D:\%%le_dir%%\exe /Y

  • 其中le_dir是一个目录从定义清单

回答

3

试试这个(清单在一个文本文件):

for /f "delims=" %%i in (list.txt) do (
xcopy "C:\test\*.exe" "D:\%%i\exe" /Y 
xcopy "C:\test\*.dll" "D:\%%i\dll" /Y 
) 

把目标文件夹中的文本文件list.txt

dir1 
dir2 
... 

EDIT1(文件夹中的脚本中定义):

set "folders=dir1 dir2 dir3" 
for %%i in (%folders%) do (
xcopy "C:\test\*.exe" "D:\%%i\exe" /Y 
xcopy "C:\test\*.dll" "D:\%%i\dll" /Y 
) 

EDIT2(如果有是文件夹名称中的空格):

set "folders="dir 1" "dir 2" "dir 3"" 
for %%i in (%folders%) do (
xcopy "C:\test\*.exe" "D:\%%~i\exe" /Y 
xcopy "C:\test\*.dll" "D:\%%~i\dll" /Y 
) 

Edit3:“)”添加。

+0

什么是list.txt?脚本数组可以在脚本中定义吗? – Xlaudius 2013-03-16 16:27:40

+0

目标文件夹在单独的文本文件'list.txt'中定义。 – Endoro 2013-03-16 16:34:25

+0

好的。这是非常好的,但是你能指定一种方法来让这些目录内联,比如'set DIRS = ...'; – Xlaudius 2013-03-16 16:35:51