FOR /D %%V in ("C:\FOLDER\\SUBFOLDER\\*") DO (
md %%V\\"subfolder01"
md %%V\\"subfolder02"
md %%V\\"subfolder03"
)
Echo "DONE!"
如果这不起作用,因为路径太深和/或文件夹名称中有许多“特殊字符”,例如空格、“-”等,则必须:
a)将目标文件夹移动到文件夹的根目录相同的驱动器(可能也将其重命名为“aaa”),在上面批量修改路径,执行它并将文件夹移回原来的位置
或
b)使用VB脚本而不是Windows批处理:
Option Explicit
Dim myFolder, mySubs
myFolder="C:\folder\subfolder"
mySubs="foo,uncleFoo"
Call AddSubFolders(myFolder,mySubs)
Call MsgBox ("Done!")
Sub AddSubFolders(targetFolder,subFolderList)
Dim FSO, targetF, subF, subSubF
Dim sFoldList, iC
sFoldList = Split(subFolderList, ",")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set targetF = FSO.GetFolder(targetFolder)
Set subF = targetF.SubFolders
For Each subSubF in subF
For iC = 0 To Ubound(sFoldList)
Call FSO.CreateFolder(subSubF & "\" & sFoldList(iC))
Next
Next
Set subF = Nothing
Set targetF = Nothing
Set FSO = Nothing
End Sub
创建一个文件并将其命名,例如“runme.vbs”,复制粘贴上面的代码,将“myFolder”的值更改为实际目标文件夹的名称,将“mySubs”的值更改为逗号分隔的文件夹名称列表喜欢添加为子文件夹,然后运行它