【发布时间】:2013-09-15 22:31:12
【问题描述】:
终端中是否有任何方法可以列出所有带有特定颜色标签的查找器文件? (即“查找所有带有红色标签的文件”
我知道这在聚光灯下是可能的。正在寻找一种将其合并到 applescript/terminal 中的方法。
【问题讨论】:
标签: macos bash terminal applescript
终端中是否有任何方法可以列出所有带有特定颜色标签的查找器文件? (即“查找所有带有红色标签的文件”
我知道这在聚光灯下是可能的。正在寻找一种将其合并到 applescript/terminal 中的方法。
【问题讨论】:
标签: macos bash terminal applescript
在 Applescript 中按标签获取文件的 Applescript 代码是(注意使用整数来定义颜色):
set yellow to 3
tell application "Finder"
files of folder "path:to:folder:" whose label index is yellow
end tell
代码是:
None = 0
Red = 2
Orange = 1
Yellow = 3
Green = 6
Blue = 4
Purple = 5
Gray = 7
【讨论】:
在终端中,您可以直接使用 mdfind。它是 Spotlight 的命令行客户端 :)
例如
$ mdfind -onlyin . -literal 'kMDItemFSLabel > 0' # labels have value 50
/cwd/labelled_file.jpg
$ mdfind -onlyin . -literal 'kMDItemFSLabel == 0'
/cwd/all.jpg
/cwd/other.jpg
/cwd/files.jpg
当然,你也可以在 shell 脚本中调用它;)
【讨论】: