![使用 folder/*/folder 创建多个文件夹”](https://linux22.com/image/1606583/%E4%BD%BF%E7%94%A8%20folder%2F*%2Ffolder%20%E5%88%9B%E5%BB%BA%E5%A4%9A%E4%B8%AA%E6%96%87%E4%BB%B6%E5%A4%B9%E2%80%9D.png)
我一直使用此行使用通配符在不同的子文件夹中创建多个文件夹:
FOR /d %A IN ("C:\users\me\desktop\test\*") do mkdir "%A\test3\"
我现在的问题是,我必须在通配符后创建多个文件夹,并且只能在已经存在的文件夹中创建test2
:
FOR /d %A IN ("C:\users\me\desktop\test\*\test2") do mkdir "%A\test3\"
我怎样才能让它工作?
答案1
通配符只能用于最后的路径的元素,因此您需要执行以下操作:
for /D %A in ("%UserProfile%\Desktop\test*") do if exist "%~A\test2\" mkdir "%~A\test2\test3"