How to Tag Files and Create Spotlight Comments on a Mac
If you’ve had your Mac for a while, you’ve got files all over the place, and you may have trouble finding them at this point. Organization, slotting this file into that folder and then into some other subfolder, is only going to get you so far. And then you have to remember where you put all those files. Sounds like you need searchable tags. In this tutorial, we’ll look at how to create tags, automate tags, search for tags, and even automate searches.
Keep it Simple: Spotlight Comments
Perhaps the simplest way to tag files is with Spotlight Comments. Spotlight Comments are especially easy if you just need to do some simple file sorting or grouping and you’re going to be using Spotlight or any app that supports Spotlight Comments.
Locate the file you want to tag. If you want to add the same tag to more than one file, you can do that, but you’ll have to tag each file one at a time. There’s no batch editing for Spotlight Comments, unfortunately. When you’ve got your file, select it and press Command+I or right-click and choose Get Info.
After editing the Spotlight Comments, you can search for the new tag in Spotlight.
Right up at the top of the Info window, there’s a place to enter Spotlight Comments. If you can’t input anything, hit the caret where the comments field should be and it will expand. Enter anything you’d like to use to describe your file. Your tags can be made up of multiple words, but Spotlight Comments are comma delimited, so remember to separate your tags with a comma.
If you can’t find your files in Spotlight after they’ve been tagged, check your Spotlight settings in System Preferences.
When you’re done, either hit the Return key or close the Info window. You can verify your tags are in place by doing a quick Spotlight search. If you can’t find your files in Spotlight after they’ve been tagged, check your Spotlight settings in System Preferences. Make sure the filetype hasn’t been excluded and that Spotlight is allowed to search the file’s directory.
I used a third-party search app to find my new Spotlight Comments.
Beyond just tagging, Spotlight Comments are a great way to add keywords to files. If you often go to the same files or applications, you can add a keyword tag that you won’t use anywhere else but in the Spotlight Comments. That way you can quickly find the files you look for most often while still keeping them organized in their respective folders.
Batch Tag with Third-Party Apps
While Spotlight Comments are really great, if you need to tag a whole lot of files at one time, you could be here all day. Luckily, I've got you covered with some apps that can help you out.
Tags, the main one we'll talk about, is an OpenMeta tagging application, and it will both add tags and do the searching for you. If you’re fed up with Spotlight’s abundance of results and know exactly what you’re looking for (and that you’ve already tagged it in Tags or another OpenMeta-compatible app), this search feature could be a real time saver. But we’re getting ahead of ourselves. First, we have to actually tag some files.
Drag-and-drop files and create new tags or select from recent tags.
Tags will display recently used tags, too, so if you’re tagging a lot of files connected to the same project, this should come in handy.
Open Tags and drag a file or files onto the tagging window. Enter all of the tags you’d like, remembering they’ll be applied to all selected files. Tags will display recently used tags, too, so if you’re tagging a lot of files connected to the same project, this should come in handy. At the end of each tag, hit enter to add it to the list of assigned tags for the file.
Your new tags will shortly be searchable in Spotlight, though when I tried searching in Alfred, a sort of Spotlight replacement, I didn’t have any luck. Thus, if you’re using Tags, you’re going to have to rely on Spotlight or the app-specific search to find your tagged files.
Go Back and Edit Those Tags
Once you’ve batch tagged files, it can be slightly more difficult to remove tags from a lot of files at once. Fortunately, Tags comes complete with a tag browser. While you won’t see any of the Spotlight Comments we created earlier, because Tags is an OpenMeta tagging app, you should see OpenMeta tags on all of your files in the tags browser, even tags left in place by previous apps.
The tag browser allows you to edit or delete tags, even those created by other applications.
Use the tag browser to batch edit previously tagged files. This is especially handy if you’ve made a big mistake, for instance, if you’ve tagged all of your recipes as “recipees” or mistagged videos as “photos.” If you find that you no longer need a tag, delete it in the sidebar. This will remove the tag from all files.
I looked at Tags above because it has a simple tagger, provides a tag browser that will read the tags from other applications, and creates tags compatible with Spotlight search. There are, however, many more OpenMeta tagging apps. You can find a list at the OpenMeta project home.
Use Tags to Create Smart Folders
Lucky for us, tags and Spotlight Comments make great criteria for Smart Folders.
You may already be familiar with Smart Folders, but if not, they’re an easy way to keep track of files that may change names or location frequently. Smart Folders are essentially saved searches, and you can add whatever criteria you’d like to that saved search.
Lucky for us, tags and Spotlight Comments make great criteria for Smart Folders. Here’s an example. I have all of the documents associated with entering grad school all over my computer. There’s an Applications folder, a folder for my essays, and a folder for financial aid documents. I have folders for course selection, too. I’d like all of that in one place, without losing the organization I’ve created, and a Smart Folder can do that.
Search for your tag/keyword.
Tag all the files you want grouped together. Try to make your tag specific, like a keyword, so that when you search for the new tag, you only find your newly tagged files. Remember, the files don’t actually have to be in the same folder and can be anywhere on your computer, but they need to be searchable by Spotlight.
In Finder, click on the File menu and select New Smart Folder. Enter your tag in the search field. You can limit your results by adding additional search criteria if you like, but hopefully your tag was specific enough that you’re only getting the files you just tagged.
You can add additional criteria if you like.
Click Save and choose a name and location for your new Smart Folder. If you want it added to the Finder sidebar, make sure that option stays checked. Once you’ve saved your Smart Folder, you can drag it anywhere you like.
If you find there are more files that need to be added to the Smart Folder or it’s a tag that is constantly being used on new files, don’t worry, the Smart Folder will automatically update with the newly tagged files.
Automate Tagging (and More)
I have one last trick up my sleeve. So you’ve got all of your important files tagged, either using Spotlight Comments or a third-party app. You’re slotting them into Smart Folders to keep all those tags organized, and when you get a new file that fits one of your tags, you make sure it gets the same treatment so it ends up in a Smart Folder, too. But wouldn’t it be easier if some of this tagging were automated?
It sure would, so we’ll try automatically adding comments with an Automator folder action and using the Hazel third-party preference pane.
Creating a Folder Action with Automator
Open Automator, located in Applications. When prompted to choose a type of Automator document, select Folder Action. In the Actions search field, enter “Spotlight Comments.” When you find the right result, double-click the action or drag it into the Folder Action pane.
There is an empty field for your Spotlight Comments. Remember, these comments will be added to all files you move to your new folder. Add your comments here, separated by commas. You can also add comments such as the date and time by selecting Variables.
Automator folder actions can add Spotlight Comments for you.
Anytime you add a file to the folder specified in the Automator folder action, your tags will be added to its Spotlight Comments and will be searchable in Spotlight.
If you want to replace all Spotlight Comments associated with the file, deselect the Append... checkbox. Otherwise, make sure you keep that checked. Click on the Choose Folder drop-down to select the folder that will perform the folder action. You can also create a new folder.
When everything’s complete, save the folder action and exit. Anytime you add a file to the folder specified in the Automator folder action, your tags will be added to its Spotlight Comments and will be searchable in Spotlight or will make it show up in any applicable Smart Folders.
Setting up Folder Rules with Hazel
Now let’s try doing that with Hazel. You’ll need to have already installed the Hazel preference pane.
Open the Hazel preference pane and add the folder you want Hazel to watch to the list of folders. With the folder selected, add a new rule to Hazel. A new window will open with conditions for your rule and the actions that will be carried out.
You can also choose from Hazel's variables.
Decide what criteria will have to be met for the rule to be implemented. It may be something as simple as all new files, or it could be new files of a specific type with a prefix in their filenames that corresponds to a project. You can add several criteria or just one.
Next, tell Hazel what to do with the file. For the purpose of this tutorial, you’ll want to tell Hazel to give the file a tag, which will add a Spotlight Comment, and you can have Hazel add as many Spotlight Comments as you’d like. It doesn’t have to stop there, though. Hazel can do all sorts of stuff, like move your files, change label colors, or even send files to the trash.
You can tell Hazel to do pretty much whatever you'd like with your files.
Don't forget to save your rule. Hazel will immediately act on anything that meets the criteria of the new rule and any files that come into the folder in the future.
Whether you prefer third-party apps or Spotlight Comments, there are lots of different ways to tag your files in OS X, and we’ve even looked at a couple of ways to automate the process. With a bit of start up effort, tags can get your untamed files well organized and make your workflow run more smoothly.
Do you have a favorite tagging app? How about another favorite Automator folder action or workflow you use for tagging your files? Let us know in the comments!