Finder’s tag system is greatly underused, and is one of very few instances in which Apple gives the user control over metadata stored as extended attributes (xattrs). Most who use tags use very little of their power. This short article accompanies my more detailed account of the technical aspects of the xattr which contains tag info, and complements it by looking beyond the xattr itself.
Finder tags are exposed to the user in the Finder’s Preferences dialog, where they are given their own section, and surprisingly powerful tools for their use and customisation.
Each tag consists of two elements: a colour (which can be none), selected from the standard range of seven: red, orange, yellow, green, blue, purple, and grey, and a text label. When you use the standard macOS tags, their text labels are simply the colour names. You can change those standard labels by Control-clicking on them, or remove them if you wish.
Adding a new tag is obvious, by clicking on the + tool at the foot of the tag list, and clicking on the – tool there removes the selected tag.
The xattr which stores a file or folder’s tag contains the two elements of each of its tags, and can hold multiple tags. When you add your own custom tags, items marked by them have a xattr which contains the label of your custom tag and its set colour from the range of seven, plus no colour.
The Finder manages tags for you. For example, if you customise one of the standard tags by changing its name, say from Red to Urgent, then the Finder automatically changes all items marked with that tag to show the label Urgent. The tag remains associated with that file or folder: when you copy that item across to another Mac, the tag remains attached to it, and on that second system should continue to show the same colour and label. The same applies to custom tags which you might add.
The important exception to this is if the item is moved using a method which does not preserve its metadata (xattrs), which occurs on some file systems such as NFS, and using some command line tools. Some backup and cloning tools may also not preserve metadata, and will strip all your tags; Time Machine preserves all metadata.
Tags are widely supported in the Finder, macOS tools, and apps. When you show tags in the Finder’s sidebar, you can view items with only a specific tag by selecting that tag in the sidebar of a Finder window. The same feature works in file open and save dialogs in all apps which use the standard macOS dialog too. You can further refine a tag-based listing by opting to sort those files in date or other orders.
There are several different ways to assign one or more tags to any file or folder, and you can use the same method to remove tags from them. Note that if you remove a tag from the list in the Finder’s Preferences, that tag is also removed from every item which was tagged with it. You can use that to your advantage if you use a custom tag to work on a specific project: when that is complete, and the documents are archived, you can search for any outlying items which still have that tag, then delete the tag in Finder Preferences once you have cleared them away.
You can tag files automatically in shell scripts, AppleScript, and many other languages supported on macOS. If you want to do this, one easy approach is to install
tag, available in Homebrew and MacPorts, or from its Github site.
There is one puzzle with Finder tags: the null tag, which is attached to a great many files, typically in ~/Documents. It has neither label nor colour associated with it, so cannot be accessed in the ways that regular tags are. It isn’t the residue left when a tag is removed from an item, as the Finder, at least, then strips aware the entire tag xattr. But something seems to be creating and using these tags which the user cannot see or access.
If you discover what these null tags are for, I’d be fascinated to hear.