Finder Tags and Terminal / by Joseph Palumbo

Apple introduced the concept of tags back in Maverick and as far as I know most people do not use them. Instead relying exclusively on dropping files into directories.

As I’m focusing on better digital organization and decluttering (something I will post about in the not too distant future) I thought tags might be a good way to help build a clear and scalable file taxonomy. And for the most part, it has been.

The problem?

I use Terminal to work with my folders and files at least half the the time, if not more. And Apple did not provide an out-of-the-box method to add/remove tags to files from CLI.

So I went to Google and this is what I found.

Google, Can I work with tags from Terminal?

A quick Google search found this article from Brett Terpstra. While I’d like to get more in depth with tags in the future, he’s right when he says, “If you’re just looking for a ready-to-go tool, grab tag and skip the rest of this.”

Rather than downloading the code from Github, I decided to look on Brew to see if it’s there.

It is!

Screenshot 2019-07-21 07.50.01.jpg

I installed tag using Brew.

First Attempt

I have a file on my Desktop called textfile

Screenshot 2019-07-21 09.03.17.jpg

Using the follow command I attached the Important tag to that file.

$ tag -a Important textfile 

Screenshot 2019-07-21 09.09.23.jpg

It worked.

You can also remove the tag using:

$ tag -r Important textfile

Making it more useful

From a previous post about solving the open command, I can pass in a number of files to the tag command like this:

$ tag -a some_tag $(ls -t *.xls | head -n5)

This will apply some_tag to the 5 most recent Excel files added to that directory.