1

是否可以定义目录列表,例如“dir1”、“dir2”,然后为每个目录执行几个操作,例如:

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

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

  • le_dir定义列表中的目录在哪里

4

1 回答 1

4

试试这个(列表在文本文件中):

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:添加了“)”。

于 2013-03-16T16:27:07.843 回答