【发布时间】:2017-12-23 01:24:05
【问题描述】:
我应该使用哪个命令(从文件或从剪贴板)向 macOS 中文件(任何文件)的“评论”部分添加评论?
这些 cmets 用于 Spotlight 索引,显然可以从 Finder (⌘+i) 手动添加,但出于我的目的,我希望能够从命令行执行此操作(以在 Bash 脚本中使用)。
【问题讨论】:
标签: bash macos terminal spotlight
我应该使用哪个命令(从文件或从剪贴板)向 macOS 中文件(任何文件)的“评论”部分添加评论?
这些 cmets 用于 Spotlight 索引,显然可以从 Finder (⌘+i) 手动添加,但出于我的目的,我希望能够从命令行执行此操作(以在 Bash 脚本中使用)。
【问题讨论】:
标签: bash macos terminal spotlight
我 found 一个不错的 sn-p,适用于 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"
【讨论】:
osascript -e 'on run {f, c}' -e 'tell app "Finder" to set comment of (POSIX file f as alias) to c' -e end file:///path/to/your.file "my comment blah blah"
注意file:// URL 前缀。于 10.15.4 验证。请注意,第一次执行此操作时会弹出一个安全对话框。
【讨论】: