> ## Content Index
> Fetch the complete content index at: https://jasontucker.blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Working with Tags in OS X
- URL: https://jasontucker.blog/working-tags-os-x/
- Published: 2015-02-21T20:32:27.000Z
- Updated: 2015-03-10T20:21:48.000Z
- Author: Jason Tucker
- Tags: #wordpress

Yesterday I wrote about how to [use tags to group applications and how to use Alfred to search for them](https://jasontucker.blog/7636/what-was-that-apps-name-again "What was that app’s name again?"). 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.

[![Sublime_Text_2_Info](https://jasontucker.blog/content/images/2015/02/Sublime_Text_2_Info.jpg)](https://jasontucker.blog/content/images/2015/02/Sublime%5FText%5F2%5FInfo.jpg)

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.

[![listtags](https://jasontucker.blog/content/images/2015/02/listtags.gif)](https://jasontucker.blog/content/images/2015/02/listtags.gif)

## 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](https://github.com/jdberry/tag?ref=jasontucker.blog)” by jdberry on GitHub. Tag can be installed using Brew or MacPorts.

**Homebrew**  
`brew install tag`

**MacPorts**  
`sudo port install tag`

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

`ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`

And read more about it here: [http://brew.sh/](http://brew.sh/?ref=jasontucker.blog)

### Installing tag using Brew

`brew install tag`

### Listing all files with tags

`tag -tgf \*`  
Outputs the following:  
`  
/Applications/Caffeine.app  
presentation  
/Applications/Coda 2.app  
dev  
web  
/Applications/CodeKit.app  
dev  
web  
/Applications/Dash.app  
docs  
documentation  
man  
web`  
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 Downloader.app movie,movies,video,videos  
/Applications/ADPassMon.app ldap,network  
/Applications/Angry IP Scanner.app admin,net,network  
/Applications/Apple Configurator.app admin,apple,net,network  
/Applications/Caffeine.app presentation  
/Applications/CleanMyDrive.app admin  
/Applications/Coda 2.app dev,web  
/Applications/CodeKit.app dev,web  
/Applications/Colloquy.app chat,irc  
/Applications/Dash.app 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/CodeKit.app`

or if I had more than one tag you could do

`tag -a dev,web /Applications/CodeKit.app`

and more than one file and more than one tag

`tag -a dev,web /Applications/CodeKit.app /Applications/Dash.app`

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

[![listtags](https://jasontucker.blog/content/images/2015/02/listtags.gif)](https://jasontucker.blog/content/images/2015/02/listtags.gif)

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  

[http://brettterpstra.com/projects/vitag/](http://brettterpstra.com/projects/vitag/?ref=jasontucker.blog)