【问题标题】:Find all OSX files with specific 'color' label查找所有带有特定“颜色”标签的 OSX 文件
【发布时间】:2013-09-15 22:31:12
【问题描述】:

终端中是否有任何方法可以列出所有带有特定颜色标签的查找器文件? (即“查找所有带有红色标签的文件”

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

【问题讨论】:

    标签: macos bash terminal applescript


    【解决方案1】:

    在 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
    

    【讨论】:

    • 他想要终端中的文件。
    • 问题是“applescript/terminal”。我认为这意味着一个或另一个。
    • 好的.. 不认为它对他有用:/ 但你是对的。没有读到最后;)对不起
    【解决方案2】:

    在终端中,您可以直接使用 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 脚本中调用它;)

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-16
      • 1970-01-01
      • 2011-07-01
      • 2014-05-09
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      相关资源
      最近更新 更多