我在.cmd文件中遇到问题。希望你能帮助我
我制作了一个复制所有文件和子文件夹(xcopy)的算法,然后将其粘贴到新目录中。
以下是代码:
@echo off
:menu
if not exist G:\ (goto 1)
md "C:\Users\x\Documents\test"
xcopy "G:\*.*" test /e /i /h /k
cls
:1
if not exist H:\ (goto 2)
md "C:\Users\x\Documents\test"
xcopy "H:\*.*" test /e /i /h /k
cls
我知道这可能会更好,但就目前而言,我的问题是我怎么能做一个“for letters loop with letters”而没有数字。因为如果我使用简单的for循环而不是带有所有驱动器号的扩展菜单会更快。
谢谢!
答案 0 :(得分:2)
for %%d in (g h) do if exist "%%d:\" (
md "C:\Users\%%d\Documents\test"
xcopy "%%d:\*.*" test /e /i /h /k
goto done
)
echo drives not found
:done
只需展开g h
即可添加您喜欢的任何驱动器。