我正在递归地搜索目录中与特定模式匹配的文件,当我得到匹配时,我想在该特定目录中创建文本文件。
我的目录结构如下:
\fldr1\1\
\fldr1\2\
\fldr1\3\
我当前的代码(powershell v5.1)
Get-ChildItem -Filter "*13000__CLMR*.PDF" -Recurse | foreach {New-Item -Path $_.Parent.FullName -ItemType File -Force -Name "DELETEME.txt"}
返回以下错误:New-Item : Cannot bind argument to parameter 'Path' because it is null.
感谢奥拉夫的答案。有人用
$_.Directory.FullName
而不是
$_.Parent.FullName