Apple introduced Smart Folders years ago, but they’re often given short shrift compared to other macOS features. While recently responding to readers’ troubles for Mac 911 and researching other stories, I discovered I’d mostly given up on a powerful option for saving recurring searches.
This is partly due to Spotlight. For many years, starting with its introduction, Spotlight indexing could be spotty or crash and re-run, and searches weren’t always as comprehensive and accurate as one could hope. That’s settled down. Even on searches that match hundreds of thousands of results on my 2014 Mac mini (across both a solid-state drive and external hard drives), Spotlight performance is pretty zippy.
In this tutorial, I’ll guide you through crafting Spotlight searches with detailed criteria that you’ll want to save as Smart Folders partly because of the hassle of re-creating them. Smart Folders take up essentially no space, and you can duplicate them and modify criteria later. By saving more Smart Folders, you’ll save time and frustration as you develop searches you want to use either frequently or from time to time.
(I wrote this tutorial with macOS Sierra, and many details work over several previous releases. However, Apple has apparently made minor tweaks that could produce different search results in previous OS releases than in Sierra.)
Set up Smart Folders
A smart folder is just a Spotlight search with criteria shown as a set of items with the option to save the query. If you start typing a search into the Spotlight field in any Finder window, you see results in that window. Click the + (plus) sign that appears at the upper right, and it’s turned into a smart folder with a Save button to retain your criteria. (This doesn’t occur if you’re in a Finder window that’s already showing a smart folder, like All My Files, a default in macOS.)
You can also choose File > New Smart Folder or press Command-Option-spacebar, and macOS brings up an empty Smart Folder in a Finder window.
Using either the File menu or keyboard shortcut also lets you scope the search: in the top bar after “Search:” you’ll see This Mac and “Name of thing here.” That name in the quotes is whatever drive or folder you had foremost in a Finder window when invoking the smart folder window. Clicking the name in quotes restricts the search to that drive or folder hierarchy regardless of other criteria, and is saved along with the smart folder.
With This Mac, you’re tapping the full Spotlight index, which covers every connected volume unless you’ve told macOS otherwise. You can exclude volumes as well as specific folders. Folder exclusion includes packages, which are a special kind of folder—such as that used for a Photos Library—that appears as a single file and can be moved like one, but actually contains a folder hierarchy. (Use the Spotlight system preference pane’s Privacy tab to either select volumes, folders, and packages after clicking the + sign or drag items in. Those items contents are removed from the search index.)
I’ll get into criteria in the next section, but you can save a Smart Folder at any time by clicking the Save button. One saved, you can modify the search by choosing action (gear) > Show Search Criteria. This is true whether you just saved a search or you open a saved Smart Folder.
There is no undo with Smart Folders and despite a Save button, all changes are made immediately even to saved searches. Whenever you delete a criterion or make another change, there’s no way to back it out. I suggest making a copy in the Saved Searches folder of a Smart Folder you want to change to avoid losing complicated constructions.
The Save dialog lets you check a box to add the search into the Finder sidebar, and it offers to store it by default in the Saved Searches folder. The Finder offers no breadcrumbs to get to that folder, but you can search via Spotlight for Saved Searches and click on the folder result, or choose Go > Go To Folder and enter
~/Library/Saved Searches to open it in the Finder.
You can also save or move Smart Folders into any folder, letting you associate them with a specific task or project.
You can perform freeform searches in a Spotlight field, using Boolean operators that let you combine conditions (like AND, OR, and NOT), but this tutorial focuses on creating folders that you can save and reuse, so we’ll open the hood on how to combine and exclude items in series by setting criteria.
When you first open a Smart Folder, only the line beginning with Search appears with a Save and + at the far right. Click + and you can add a criterion. By default, macOS adds Name, which matches file and folder names, as well as names embedded in certain fields (like email subject lines).
The popup field that has Name in it also contains several other items: Last Opened Date, Contents, Created Date, Last Modified Date, File Size, and Kind. Each of those has additional popup menus and fields that correspond to the kind of filter you can apply.
There’s also an Other menu: choose it and macOS displays the Select a Search Attribute list, which includes both system items and Spotlight criteria added by installed apps. If you use any of these frequently, you can check the In Menu box for the line on which it’s described. You can also uncheck items you never use.
I’ve found that some criteria make no sense being there. In my list, I see one related to a password prompt that’s clearly misplaced. In other cases, applying the criteria seems to have no effect except to find no matches.
Many of the Other criteria have highly specialized uses. For example, if you’re trying to find audio files with more than one channel, you can use the Audio Channels criterion, which also only matches against files macOS recognizes as containing audio content.
Many parameters have a filter pop-up that lets you reduce the query’s scope for text or for numbers. For text, you see Matches, Contains, Begins With, Ends With, Is, and Is Not. The difference between Matches, Contains, and Is (and the logically reversed Is Not) is as follows:
- Matches finds the start of a word in text
- Contains matches against text that also appears within word boundaries
- Is/Is Not only match on exact text
The Matches and Contains filters are often very, very close. In fact, I had to perform a number of exclusive tests to figure out the difference, because Spotlight marks “words” very broadly. Thus, searching for
fleishman using Matches finds files with names that contain
Glenn Fleishman but also
GlennFleishman (intercap F) but not
glennfleishman (no cap F). Matches sees the intercap as a word boundary. If I want both
glennfleishman, I have to use Contains.
You’ll probably most frequently use text filtering against Name and Contents. The Contents field searches against the full text of any document that Spotlight either can index natively (like text, HTML, and so forth), and any installed software that adds the details to Spotlight to allow text indexing. (Not all indexable files can be previewed through Quick Look, which is a separate framework.)
For numeric values, you choose among Equals, Is Greater Than, Is Less Than, or Is Not, which are self-explanatory. You may also be able to select units, as with File Size, which offers KB, MB, and GB as pop-up options.
Date-related fields provide a lot of relative values: Within Last X Time Units (Days, Weeks, Months, Years); Exactly, Before, and After (date); Today, Yesterday, This Week, This Year, and This Month.
With criteria in mind, let’s put this all together.
Grouping criteria to drill into results
Here’s the most salient thing to remember: all the normal criteria you set are linked together as a series all of which have to all be true. So if you want files that have the word “Lens” in them modified in the last year that are larger than 10K, you simply set three criteria. These are Boolean ANDs: this AND that AND the other must be true to match.
- Name matches
- Last modified is within last 1 years
- File size is greater than 10 KB
You can imagine all sorts of combinations like this that match aimless searches you may have done before—I know I can, because I’ve been replacing them with Smart Folders. For example, I often create screen captures within macOS using its built-in shortcut, and I sometimes rename and move them. So I created a complicated query that filters for files that are PNG images (Kind is image PNG), created in the last seven days, and larger than 30K. This sweeps in almost everything I need. (Smaller PNGs are usually part of web-based help in apps.)
What if you don’t want to AND things, but to OR and NOT them? A simple Option toggle helps. Hold down the Option key while Spotlight criteria show and the + button next to each criterion will change to an ellipsis (…). If you click the …, the Finder adds an “Any of the following are true” grouping below that line.
Those groups default to Any, but you can also choose All or None. Any, All, and None correspond to Boolean operations for OR, AND, and NOT. The All option is included even though AND is the default for top-level criteria, because you can nest groupings. You can stick an All as a sub-query within an Any, which an example would help better explain.
Let’s say you wanted to find different sorts of files that contained the same text in different places. You want every file that says “TPS Reports” in its text, but also any image or PDF that has TPS Reports in its name, even if it’s not in its contents. I’d go about it this way (see the movie below to follow along and the figure for the final configuration):
- Create a new smart folder (File > New Smart Folder).
- Hold down the Option key and click … on the Name line. (Keep Name there: there’s a bug that I describe later.)
- Leave Any alone and Option-click to its right twice to create two sub groupings.
- Change both sub-groupings from Any to All.
- For the first sub-grouping, add a criteria and set the first to “Kind is PDF” and “Name contains
- For the second sub-groupings, set it to “Contents contains
The schematic description of that would be “kind is PDF AND name contains
TPS reports OR contents of any file contain
You can also use None as a powerful way to exclude items. For example, you might want to find all images except BMP files. You can set the main criterion to be “Kind is Image” and then a grouping set to None that has “Kind is BMP.” (If Kind allowed Is Not that would be simpler, but you have to use this workaround.)
Changing the order in which results are displayed
On top of choosing what’s matched, you might find that with many files, the way in which results are grouped into categories could help. As with regular Finder windows, you have both Arrange By and Sort By. These let you groups results in ways that help a lot with searches.
You can toggle between them by holding down the Option key while selecting or after selecting the View menu or, in a Finder window, the action (gear) menu or the Change the Item Arrangements By menu (if you’ve added that to the default toolbar). Another way to access these settings is to open the View Options floating window: press Command-J, choose View > Show View Options, or Control-click on a window and select Show View Options. The window has Arrange By and Sort By as separately labeled pop-up menus.
Arrange By, when set to None, has no effect. However, when you select a sort condition from it, the Finder creates relevant headings, like years or sizes. For example, you can Arrange By Size and Sort By Date Last Opened, and all the files are grouped in ranges, like 100MB to 1GB, 1MB to 10MB, and so forth, and then sorted by last opened date within that.
I often like to Arrange By a date parameter, like Date Added, as this works for downloaded files that might have a separate creation and modification date that’s preserved, but your interest is when it was added to your computer.
Bugs and omissions
Smart Folders have a few bugs, despite the number of releases they’ve gone through. I’ve discovered that creating criteria in the wrong order prevents you from adding more. For instance, this occurs with Any/All/None groupings. If you add a grouping and then delete regular criteria lines (such as the Name line that’s added by default for all new Smart Folder searches), you cannot create a new criterion that’s not nested in the group. You have to delete all criteria and start over. (Below is a short movie to demonstrate.)
Oddly and irritatingly, there are no parameters that let you select folder paths or Unix file paths. This would be extremely useful for setting a scope or excluding folders, but it’s a limitation that I’ve found discussed extensively when people want to pick and choose what’s included. It’s beyond the current Spotlight design approach as implemented both in the Finder and even through twiddling the underlying XML file of a Smart Folder that has parameters spelled out in text.
You can only scope to a folder by selecting it in the Finder, creating a new Smart Folder, and selecting it in the top bar; you can only exclude folders for all searches (a global exclusion) using the Spotlight preference pane Privacy tab. This makes Smart Folders substantially less useful, and it’s a long-running surprising omission. Some third-party search tools, like HoudahSpot, can use Spotlight results while filtering out directories or paths you enter.
Even after several years of inclusion in OS X and macOS, Apple still has room to mature Smart Folders.
Smart Folders let you leverage a computer into remembering and repeating tedious tasks for you, but you can modify them later as your needs change. There’s no penalty or overhead to creating many Smart Folders, and you’ll find yourself creating them as adjuncts to projects and an alternative to a regular folder view.