查找具有特定'color'标签的所有OSX文件



终端中有什么方法可以列出所有带有特定颜色标签的查找器文件吗?(即"查找所有带有红色标签的文件"

我知道这在聚光灯下是可能的。寻找一种方法将其合并到Applescript/终端中。

在终端中,您可以直接使用 MDFIND。它是聚光灯:)的命令行客户端

例如

$ 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 脚本中调用它;)

例如,SRC 例如:https://apple.stackexchange.com/questions/31919/how-do-you-list-items-with-and-without-labels-from-the-terminal

在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

最新更新