tso*_*kis 7 macos command-line metadata
我正在从事一个涉及从文件读取和写入元数据的项目。在 Mac 上,通过右键单击并选择文件上的“获取信息”,您可以查看和编辑某些元数据。
我找到了一种上传标签的方法(在这里找到了非常有用的工具)。现在我需要一种方法来从命令行更改文件的“注释”。
有没有办法做到这一点?
非常感谢您提前!
l'L*_*L'l 11
你可以使用全局变量NSMetadataItemCommentKey的NSMetadataItem:
斯威夫特:
let NSMetadataItemCommentKey: String
Run Code Online (Sandbox Code Playgroud)
目标-C:
NSString *const NSMetadataItemCommentKey;
Run Code Online (Sandbox Code Playgroud)
另一个(快速)的方式,这可能做可能是通过调用Applescript来自 bash:
update_comment.sh
#!/bin/bash
filepth="$1"
updated="$2"
comment=$(mdls -r -nullMarker "" -n kMDItemFinderComment "$filepth")
printf "%s ( comment ): %s\n" "${filepth##*/}" "$comment"
printf "%s ( updated ): " "${filepth##*/}"
/usr/bin/osascript -e "set filepath to POSIX file \"$filepth\"" \
-e "set the_File to filepath as alias" \
-e "tell application \"Finder\" to set the comment of the_File to \"$updated\""
Run Code Online (Sandbox Code Playgroud)
简介:
$ sh update_comment.sh /path/to/file "I'm the NEW comment"
Run Code Online (Sandbox Code Playgroud)
结果:
file ( comment ): I'm a comment
file ( updated ): I'm the NEW comment
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1320 次 |
| 最近记录: |