在 macOS 中使用命令行向文件添加(Spotlight)注释

Roe*_*oel 5 macos bash terminal spotlight

我应该使用哪个命令将评论(来自文件或剪贴板)添加到 macOS 中文件(任何文件)的“评论”部分?

这些注释用于 Spotlight 索引,显然可以从 Finder (?+i) 手动添加,但出于我的目的,我希望能够从命令行添加(在 Bash 脚本中使用)。

macOS 中“信息”对话框的屏幕截图

The*_*ius 3

发现了一个在 macOS 10.13 中适合我的好片段:

osascript -e 'on run {f, c}' -e 'tell app "Finder" to set comment of (POSIX file f as alias) to c' -e end "/path/to/your.file" "hello world"
Run Code Online (Sandbox Code Playgroud)