Mac|Life

Tagging files in Terminal

How can I add tags to files by using Terminal commands?

-

Access to tags in Terminal can be difficult because they’re actually stored in files’ extended attributes. You can set one standard colored tag in the com.apple. FinderInfo attribute.

In order to set multiple or custom tags on a file, you need to access com.apple.metadata :_kMDItemUse­rTags instead. This is the extended attribute that Apple exposes most to the user (in Finder), but there is no convenient access to it in Terminal. The built-in command xattr, for displaying and manipulati­ng extended attributes, is made more difficult to use because tags are stored in a binary format, which is hard to handle outside a programmin­g language like Swift or Python.

A third-party command named tag is available via Homebrew, MacPorts, or from

github.com/jdberry/tag. This should make your task a lot simpler and more flexible. There’s more info at bit.ly/ecxattr via The Eclectic Light Company website, but bear in mind that it gets quite technical.

 ??  ?? Tags are easy to add to files in Finder, but they’re tougher to handle in Terminal.
Tags are easy to add to files in Finder, but they’re tougher to handle in Terminal.

Newspapers in English

Newspapers from Australia