matlab - 使用 Powershell 函数(从 MATLAB 调用)编辑文件元数据
问题描述
我正在尝试使用 Powershell 以编程方式访问本地文件元数据(类似于 .mp3 文件中的“作者”或“专辑”等字段)(主要原因是在我看来,这似乎是从 MATLAB 实现这一目标的最可行方法)。
到目前为止,我已经设法读取了元数据。我想出了以下功能:
param(
[string]$folderName = "C:\temp\Powershell\test",
[string]$fileName = "test.txt",
[string]$attrNameToSearch = "Size"
)
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.namespace($folderName)
$iAttr = 0
while($objFolder.getDetailsOf($objFolder.items, $iAttr) -ne $attrNameToSearch) {
$iAttr += 1
}
$file = $objFolder.ParseName($fileName)
$attrValue = $objFolder.getDetailsOf($file, $iAttr)
return $attrValue
它似乎在 ISE 以及当我从 MATLAB 调用它时都可以完美运行:
cmd = sprintf(['powershell -file psFunction4.ps1 -folderName c:\\temp\\Powershell\\test -fileName ', fileNames{iF}, ' -attrName Size']);
[~, b] = system(cmd)
现在的问题是:有没有办法使用类似的方法来编辑元数据?
提前致谢。
解决方案
推荐阅读
- c - strerror_r 示例
- xamarin.android - 捕捉 System.Reflection.TargetInvocationException
- node.js - 获取 JSDoc 注释 Node js
- node.js - Nodejs 扩展运算符在返回的对象中返回一些意外的键
- flutter - 如何通过 shared_preferences 在我的项目中使用 List
- python-3.x - 在可迭代(语法糖)的索引 i 处查找项目?
- javascript - 在画廊中显示 firebase 图像放大
- git - 我必须在 PC 上安装什么才能使用 GIT
- python - Keras plot_model 在模型架构中将问号替换为 None
- css - flask_asset 似乎找不到 sass 文件,但目录没问题