有关使用PowerShell Select-String,exiftool(-k)的问题 [英] Question about using PowerShell Select-String, exiftool(-k)
问题描述
在PowerShell脚本中,我尝试使用Select-String
过滤以下exiftool(-k).exe
命令的输出.
In a PowerShell script I'm trying to filter the output of the exiftool(-k).exe
command below, using Select-String
.
我尝试了许多排列,但没有任何效果,而且我总是看到未过滤的输出.我该怎么做才能过滤此命令的输出?
I've tried numerous permutations, but none work, and I always see the unfiltered output. What do I need to do to filter the output of this command?
Start-Process -FilePath "C:\PowerShell\exiftool(-k).exe" -ArgumentList test.jpg |
Select-String -pattern 'GPS' -SimpleMatch
推荐答案
命名不便.将其重命名为exiftool.exe并在没有启动进程的情况下运行它.
The naming is inconvenient. Rename it to exiftool.exe and run it without start-process.
rename-item 'exiftool(-k).exe' exiftool.exe
C:\Users\bfbarton\PowerShell\exiftool.exe test-jpg | Select-String GPS
或
$env:path += ';C:\Users\bfbarton\PowerShell'
exiftool test.jpg | Select-String GPS
网站建议将其重命名为"exiftool.exe"以供命令行使用". https://exiftool.org .即使在Unix中,如果不转义括号也将无法正常工作.
The website recommends to 'rename to "exiftool.exe" for command-line use'. https://exiftool.org . Even in unix, it wouldn't work without escaping the parentheses.
还有使用调用运算符的选项.使用制表符补全实际上可以做到这一点:
There's also the option of using the call operator. Using tab completion actually does this:
& '.\exiftool(-k).exe' test.jpg | select-string gps
这篇关于有关使用PowerShell Select-String,exiftool(-k)的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!