programmatic access to Finder labels X.6.8

Discussion in 'Mac Programming' started by zeppenwolf, Nov 18, 2013.

  1. zeppenwolf macrumors regular

    zeppenwolf

    Joined:
    Nov 17, 2009
    #1
    Is there [subject line] ?

    By "Finder labels" I mean the 7 colors you can attach to a Finder object, the names of which you can adjust through Finder menu "Preferences..."

    I can't find any programmatic access, ( I mean, a NS or CF call, not AS ) to these on X.6.8 ( sorry, can't remember which damn cat this is), although I have *some* AS access.

    In Applescript I can get/set the "label number [n]" for a Finder item, but I can't get or set the name of it. In the AS Editor's Open... Finder Dictionary, I get this:

    label n : (NOT AVAILABLE YET) [!!!] A Finder label (name and color)

    PS: On my MBP, the labels are colored from top to bottom like this:

    Red
    Orange
    Yellow
    Green
    Blue
    Purple
    Grey

    Yet, the "number" of the label, according to AS, goes like this:

    0 <no label>
    2 Red
    1 Orange
    3 Yellow
    6 Green
    4 Blue
    5 Purple
    7 Grey
     
  2. MeFromHere macrumors 6502

    Joined:
    Oct 11, 2012
    #2
    If you make a smart search that operates on the label, save the search, and Get Info on the smart search, you'll see "kMDItemFSLabel" as part of the query.

    There's a lot of info out there if you Google kMDItemFSLabel. Some of it might be useful. I didn't have time to dig into all the suggestions.
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    The implementation of labels (and tags in Mavericks) is discussed in some technical detail in the ArsTechnica Maverics Review. I do not believe there is an API to access the label outside of the standard file meta data APIs...
     

Share This Page