![]() ![]() Prints on that sample folder: /tmp/test/DSC_2930-m.jpg Here is a demo of all three: from pathlib import Pathįor fn in (fn for fn in p.glob('*') if fn.is_file()): The third is to use the PyPi module osxmetadata: import osxmetadata If ':_kMDItemUserTags' in xattr.listxattr(fn): The second is to use the program tag which can be installed with brew: from subprocess import run, PIPE There are three ways that I have used to get the Finder tags into Python.įirst, use xattr to generate a binary plist of extended attributes from the key ':_kMDItemUserTags' and then convert that to a list with plistlib: import xattrīpl=xattr.getxattr(fn, ':_kMDItemUserTags')įor e in plistlib.loads(bpl, fmt=plistlib.FMT_BINARY)] Notice that some files have multiple tags. Label_rev = Īpp('Finder').items.label_t(label_rev) > set_finder_label("/tmp/example.txt", "blue") Idx = app('Finder').items.label_index.get() """Get the Finder label colour for the given path ![]() # Note these label names could be changed in the Finder preferences, Using this module, here are two functions to get and set the finder labels with appscript version 1.0: from appscript import app The macfile module is part of the appscript module, and was renamed to mactypes in " - 0.2.0"
0 Comments
Leave a Reply. |