是否可以定义目录列表,例如“dir1”,“dir2”然后为每个目录执行一些操作,例如:
xcopy C:\test\*.dll D:\%%le_dir%%\dll /Y
xcopy C:\test\*.exe D:\%%le_dir%%\exe /Y
其中le_dir
是定义列表中的目录
答案 0 :(得分: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:“)”已添加。