Apple - Are the OSX Mavericks tags visible from the command line?
Yes, you can find files that have a given user tag using mdfind
.
Create a file and assign it a a custom tag in Finder.
Then go in a terminal; you will find it with:
mdfind "kMDItemUserTags == Math || kMDItemUserTags == Programming"
or
mdfind "kMDItemUserTags == Math && kMDItemUserTags == Programming"
See also -onlyin aFolder
to restrict the search.
I didn't check how complex these boolean expressions can be, but these two examples work.
You can pipe the output to ls
like this:
mdfind "kMDItemUserTags == mathTag || kMDItemUserTags == anotherTag" \
| while read f; do ls "$f"; md5 "$f"; done
Also, mdfind has an option "-0"
-0 Use NUL (``\0'') as a path separator, for use with xargs -0.
which can be practical with nasty filenames.
I'm assuming they will be an xattr like they currently are on 10.8.3 (and older)
Currently, you can view which extended attributes a file has with ls -l@
.
But to see the contents of the attributes, you have to use xattr
.
You can get all tags of a file with:
mdls -name kMDItemUserTags filename