macos - Powershell Core 读取文件元数据
问题描述
我需要一种在 macOS 上使用 Powershell Core 7.x 读取文件元数据的方法。
在 MS Windows 环境中,我能够使用Shell.Application
COM 对象和getDetailsOf()
方法来检索信息。但是,我在 macOS 上的 PowerShell Core 中找不到此选项。
我发现有人在 PowerShell 核心中使用外部命令(我猜有些是用 python 编写的)来检索信息,但我想只使用 PowerShell 来做到这一点。
有谁知道这是否可以通过 Powershell 内核实现?
谢谢
解决方案
Start-Process
您可以使用cmdlet 并捕获此过程的输出,而不是使用“Shell.Application COM 对象”来执行外部工具:
$f = New-TemporaryFile
Start-Process exiftool -ArgumentList "myImage.jpg" -RedirectStandardOutput $f.FullName -Wait
$result = Get-Content -Path $f.FullName
Remove-Item -Path $f.FullName
# Now, the result of the exiftool is available in $result for further processing
推荐阅读
- hyperledger-fabric - BNA 安装请求超时
- phpstorm - 是否有键盘快捷键可以在当前行中从头到尾选择代码?
- sql - 从 SQL Server 2008 的结果中查找两个连续行之间的差异
- c# - 将复杂的 json 转换为 c# 对象
- c11 - atomic_load() 和 assignment 有什么区别?
- django - 'profile' 这个词是 Django 中的构建功能吗?
- go - 如何将函数指针传递给 Go 中的 C 代码
- google-app-engine - 如何在 objectify 中编写 GQL `CONTAINS` 比较器查询
- sql - ORA-00904: "PREV_TEMP": 带有 LAG 函数的无效标识符
- msbuild - 通过参数向 MSBuild 提供多个构建配置并让它们并行构建