好的,寻求有关Powershell的帮助。我需要在目录的大约200个文件夹中创建一个具有相同名称的子文件夹。到目前为止,我有这个:
$folder = NewFolderName
new-item -type directory -path \\servername\directory\directory\$folder -Force
是否可以在所有200个文件夹中创建单个文件夹?
尝试以下代码片段:
$parent = '\\servername\directory'
$folder = 'NewFolderName'
Get-ChildItem -Path $parent -Directory |
ForEach-Object {
New-Item -WhatIf -Type Directory -Path (
Join-Path -Path $_.FullName -ChildPath $folder) -Force
}
-WhatIf
不得早于调试就删除风险缓解参数。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句