Sub topic 11
Saving searches as smart folders
This chapter assumes you can run a Finder search (Command-F) and apply tags, both covered earlier. It shows how to save a search so you can reuse it.
What a smart folder is
A smart folder is a saved search that looks like a folder. It does not hold files. Each time you open it, the Finder runs the search again and lists whatever matches now. A new file that fits your rules appears on its own, and a file that no longer fits disappears from the list.
Smart folders use the Spotlight index. Anything excluded from Spotlight, such as a folder you added in System Settings under Spotlight's search privacy list, never shows up in the results.
Building one
- In the Finder, choose File > New Smart Folder. You can also press Command-F in any window.
- Choose where to search from the bar at the top: This Mac, or a specific folder.
- Click the + button at the right to add a rule. The first menu defaults to Kind. Open it and choose Other... to see every attribute available.
- Pick the attribute, such as Kind, Last opened date, or Tags, and set its value.
- Add more rules. By default a file must match all of them.
- Click Save, enter a name, and keep Add To Sidebar ticked.
Hold Option while clicking + to get a group that matches any, all, or none of its rules. For example, a group of rules for "Kind is PDF" and "Kind is Image", set to match any, finds either type.
Useful examples
| Goal | Rules |
|---|---|
| Everything needing attention | Tags contains Urgent |
| Recent work | Last opened date is within the last 7 days |
| Large clutter | File size is greater than 500 MB |
| Receipts to file away | Kind is PDF, and Name contains "receipt" |
The first row matches the Terminal query mdfind -onlyin ~/Documents "kMDItemUserTags == 'Urgent'". Both ask the same Spotlight index.
Editing and managing
To change the rules, open the smart folder and choose Show Search Criteria from the Action menu (the gear icon) in the toolbar. Changes are saved when you click Save again. Smart folders are stored as files ending in .savedSearch, by default in ~/Library/Saved Searches.
Common errors
- Deleting from inside a smart folder deletes the real file. The listed items are the actual files, not copies. Moving one to the Trash removes it from its original location.
- Expecting a missing file to appear. Check that the search location includes the folder, that the folder is not excluded from Spotlight, and that the file has finished indexing (iCloud files that have not been downloaded may match by name only).
- Rules that are too narrow. A "Name" rule matches only the file name. Use "Contents" if you want text inside documents.
- Deleting the smart folder to clean up. This removes only the saved search. Your files stay where they are.
Exercise
You build a smart folder with the rule "Tags contains Urgent" and then drag one of its listed files to the Trash. What happens to the file, and why?
Show answer
The file is moved to the Trash from its real location. A smart folder only lists matching items, so the files it shows are the originals. To stop a file appearing without deleting it, remove the Urgent tag instead.