【发布时间】:2020-09-17 22:00:35
【问题描述】:
我有一个带有文件名的 txt 文件(即01234.tif),我想用它来过滤 Get-ChildItem cmdlet。我做了
$filenames = Get-Content filenames.txt
(也试过| Out-String)
然后
Get-ChildItem . -Include $filenames | ForEach {if (!(Test-Path -Path ./jpeg/$_.Basename+".jpg")) {some imagemagick processing}}
但它什么也没做。有趣的部分是它适用于排除,因为
Get-ChildItem . -Exclude $filenames > exclude.txt
写入预期的行数。我在这里错过了什么?
Get-Content filenames.txt | ForEach (path test) {imagemagick}
运行但复制所有项目,因此路径检查或 Get-Content 未按预期工作。
【问题讨论】:
标签: powershell