好吧我需要创建一个脚本(VBS,Batch,无论什么工作),它将采用现有的文件结构,复制它并在每个文件夹的新结构中创建特定的子文件夹。实施例
Current structure :
Folder 1
Folder 2
Folder 3
脚本将采用这些,并在另一个文件夹中将重新创建以下结构:
Folder 1
*-- Folder X
*-- Folder Y
*-- Folder Z
Folder 2
*-- Folder X
*-- Folder Y
*-- Folder Z
答案 0 :(得分:0)
这个powershell脚本应该做你想做的事情:
$source_dir="c:\temp\structure"
$destination="c:\desination"
$model=ls $source_dir -dir
$model |%{
$name=$_.name
new-item -itemType directory -path $destination\$name
("X","Y","Z")|% { new-item -itemType directory -path $destination\$name\$_}
}
答案 1 :(得分:0)
@echo off
set "source=c:\source"
set "target=c:\target"
for /d %%f in ("%source%\*") do for %%t in ("X" "Y" "Z") do (
echo md "%target%\%%~nxf\%%~t" 2>nul
)
目录创建仅响应控制台。如果输出正确,请在echo
md
命令
答案 2 :(得分:0)
VBScript解决方案:
Set fso = CreateObject("Scripting.FileSystemObject")
src = "C:\foo"
dst = "C:\bar"
newFolders = Array("X", "Y", "Z")
For Each sf In fso.GetFolder(src).SubFolders
dir = fso.BuildPath(dst, sf.Name)
fso.CreateFolder dir
For n In newFolders
fso.CreateFolder fso.BuildPath(dir, n)
Next
Next