File 批处理文件以根据另一个结构创建文件结构

File 批处理文件以根据另一个结构创建文件结构,file,batch-file,vbscript,structure,File,Batch File,Vbscript,Structure,好的,我需要做一个脚本(VBS,批处理,任何工作),将采取现有的文件结构,复制它,并在新的结构中为每个文件夹创建特定的子文件夹。范例 Current structure : Folder 1 Folder 2 Folder 3 脚本将获取这些内容,并在另一个文件夹中重新创建以下结构: Folder 1 *-- Folder X *-- Folder Y *-- Folder Z Folder 2 *-- Folder X *-- Folder Y *-- Folder Z 此powershe

好的,我需要做一个脚本(VBS,批处理,任何工作),将采取现有的文件结构,复制它,并在新的结构中为每个文件夹创建特定的子文件夹。范例

Current structure :
Folder 1
Folder 2
Folder 3
脚本将获取这些内容,并在另一个文件夹中重新创建以下结构:

Folder 1
*-- Folder X
*-- Folder Y
*-- Folder Z
Folder 2
*-- Folder X
*-- Folder Y
*-- Folder Z

此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\$_}

}
目录创建只回显到控制台。如果输出正确,请在
md

VBScript解决方案之前删除
echo
命令:

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

这个问题毫无意义。开始和结束文件夹结构与问题正文不一致。您说您正在复制一个现有的结构,但您的结果缺少任何这样的复制。
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