Working with Tags in OS X 1

Yesterday I wrote about how to use tags to group applications and how to use Alfred to search for them. This post will be how to work with Tags in OS X and ways to work with them from both the GUI and the Command Line.

How to add tags to files

The easiest way to add tags to your files is by selecting the file, pressing ⌘ and i to open the Get Info window for that file. From there you can add your tag by typing it in the text box on the top.


You can add multiple tags by pressing enter after each one.

View all of the files you tagged

After tagging a few of your files you can find them by that tag a few ways. One way to do this is to click on View and then Show Sidebar or press ⌥ ⌘ P  (Option, Command and P) to open the sidebar (if it wasn’t open already) then click on Show next to Tags and then select the tag. On the main pane to the right you’ll see the result of the tag regardless where it’s at in the filesystem.


Working with Tags in the command line

Working with tags in the command line isn’t easy but there are some tools to do this. The one I found to be the most helpful is called “tag” by jdberry on GitHub. Tag can be installed using Brew or MacPorts.

brew install tag

sudo port install tag

If you don’t have either installed you can install my favorite, Brew using this command:

ruby -e "$(curl -fsSL"

And read more about it here:

Installing tag using Brew

brew install tag

Listing all files with tags

tag -tgf \*
Outputs the following:


This output shows the file and then the various tags associated with it below. There are a few switches you can do to change this output, removing the -g has it display on one line per file:

tag -tf \*
/Applications/4K Video movie,movies,video,videos
/Applications/ ldap,network
/Applications/Angry IP admin,net,network
/Applications/Apple admin,apple,net,network
/Applications/ presentation
/Applications/ admin
/Applications/Coda dev,web
/Applications/ dev,web
/Applications/ chat,irc
/Applications/ dev,docs,documentation,man,web

Adding tags to a file

Adding a tag to a file is easy with this tool.

tag -a dev /Applications/

or if I had more than one tag you could do

tag -a dev,web /Applications/

and more than one file and more than one tag

tag -a dev,web /Applications/ /Applications/

Tags has a few other options

    tag -a | --add  ...     Add tags to file
    tag -r | --remove  ...  Remove tags from file
    tag -s | --set  ...     Set tags on file
    tag -m | --match  ...   Display files with matching tags
    tag -l | --list ...           List the tags on file
    tag -f | --find               Find all files with tags

Using tags


With the left sidebar on you can select the Tags below the heading and then on the right it will display the filtered list of the items.

Other CLI Solutions

Brett Terpstra has a great CLI tool that does Tagging and makes batch tagging super simple

Maybe related content

Likes, Bookmarks, and Reposts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.