【发布时间】:2021-12-18 02:40:28
【问题描述】:
我正在尝试根据文件名中任何位置可能出现的文本移动 .pdf,但它不起作用。它执行没有错误,但不会移动文件。
文件名中带有“Sold”的所有 .pdf 文件都放在一个位置,文件名中没有“sold”的所有 .pdf 文件都放在另一个位置。
get-childitem -Recurse -path $sourcePathPDF {-filter '*.pdf' -and '*Sold*'} | move-item -Destination $destinationPathSoldPDF
get-childitem -Recurse -path $sourcePathPDF {-filter '*.pdf' -not '*Sold*'} | move-item -Destination $destinationPathPDF
我是否过滤/使用 -not 不正确?
感谢您的帮助。
【问题讨论】:
-
你不需要
-not,你需要-notlike:Get-ChildItem -Recurse |Where-Object { $_.Name -like '*.pdf' -and $_.Name -notlike '*Sold*'}
标签: powershell