Powershell 在多个文件夹中创建多个文件夹。

Powershell 在多个文件夹中创建多个文件夹。,powershell,command-line,Powershell,Command Line,我想在多个文件夹中创建多个文件夹,但只在以位置结尾的文件夹中创建 要创建的文件夹 06.8 Principal Designer (PD) 06.9 Structural Engineering Registry (SER) 要在中创建的文件夹 4000 Project Title, Location 4001 Project Title, Location 4002 Project Title, Location ... 4999 Project Title, Location 例如: X

我想在多个文件夹中创建多个文件夹,但只在以位置结尾的文件夹中创建

要创建的文件夹

06.8 Principal Designer (PD)
06.9 Structural Engineering Registry (SER)
要在中创建的文件夹

4000 Project Title, Location
4001 Project Title, Location
4002 Project Title, Location
...
4999 Project Title, Location
例如: XXXX项目名称,位置\06。报告\06.8主要设计师(PD)

我当前的非工作代码

for /d  %a in ('dir c:\temp\temp\*location ') do md 'C:\temp\temp\%a\06. Reports\06.8 Principal Designer (PD)'

您的代码看起来像
cmd
而不是PowerShell。假设您打算使用常规命令提示符,我将回答这个问题

要在目录上迭代,请对/d使用

for /d %a in (C:\Temp\Temp\*location) do md "%a\06.8 Principal Designer (PD)"
单引号对于
cmd.exe
,不是特别的;在包含空格的文件名周围使用双引号。

在PowerShell中

$dirtocreate =('06.8 Principal Designer (PD)', '06.9 Structural Engineering Registry (SER)')
Get-ChildItem "c:\temp\temp\*Location" -Directory | %{$dir=$_.FullName;$dirtocreate | %{New-Item -ItemType Directory -Path "$dir\$_" } }