繁体   English   中英

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

[英]Adding (Spotlight) comments to file using the command line in macOS

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

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

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

发现了一个适用于 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 上验证。 请注意,您第一次执行此操作时会弹出一个安全对话框。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM