Sub topic 8
Editing and refining smart folder criteria
A smart folder stores a search, not a set of files. You can change that search at any time, and the folder's contents update to match. This chapter covers how to open and edit the criteria, how to combine them, and how to avoid the mistakes that make a smart folder return too much, too little, or the wrong things.
Prerequisites
This chapter assumes you have read the previous chapter on creating and saving a smart folder. You should also know how to apply tags and how Spotlight metadata supports search. You need to be comfortable using Finder menus and the toolbar.
What "editing" a smart folder means
A smart folder is a saved query. Editing it changes the query and nothing else. No file moves, and no file is renamed or deleted. If you remove a criterion, files that now match appear in the folder. If you add one, files that no longer match disappear from the view, but they stay where they are on disk.
This makes editing safe. You can experiment with criteria and undo your change without touching your documents.
Opening the criteria
To edit a smart folder:
- Open the smart folder from the sidebar or from the folder where you saved it.
- Click the Action button (the circle with three dots) in the toolbar.
- Choose Show Search Criteria. The criteria bar appears below the toolbar.
Each row in the bar is one rule. A rule has three parts: an attribute (such as Kind, Last Modified Date, or Tags), an operator (such as "is", "contains", or "within last"), and a value.
To change a rule, use the pop-up menus in its row. To add a rule, click the plus (+) button at the right end of any row. To delete a rule, click the minus (−) button at the right end of that row.
Changes to a saved smart folder are not always written back automatically. Look for a Save button at the right end of the criteria bar. If it appears, click it to store your changes. If you skip this step, the folder reverts to its earlier criteria the next time you open it.
Choosing the search scope
Above the results is a scope bar. It controls where Finder looks:
- This Mac searches every indexed location.
- A folder name (for example, Documents) searches only that folder and its subfolders.
- Shared searches mounted network locations.
The scope is part of the saved search. A smart folder with the scope set to This Mac can return files from any folder, including old backups and downloads. If a folder returns files you did not expect, narrow the scope first. It is often the quickest fix.
Adding and changing criteria
By default, a new rule joins the others with "all": a file must meet every rule to appear. This is called an AND relationship.
Adding more attributes
The attribute menu in a rule shows common choices first, such as Kind, Last Opened Date, and Created Date. To use others, choose Other… at the bottom of the menu. A dialog lists every searchable attribute. Tick the box beside In Menu for attributes you use often, so they appear in the menu later.
Useful attributes for refining a smart folder include:
| Attribute | Typical use |
|---|---|
| Kind | Limit results to PDFs, images, or documents |
| Last Modified Date | Show files changed in the last week or month |
| Tags | Match items with a given tag |
| File Size | Find large files |
| Name | Match part of a file name |
| Contents | Match text inside files |
Matching any rule instead of all
Hold the Option key while you click the plus button. The plus changes to an ellipsis (…), and a new rule row appears with its own menu. From it you can choose any, all, or none. This lets you build groups such as "Kind is PDF or Kind is Pages", combined with other rules that must always apply.
Use these groups carefully. A mix of "any" and "all" is easy to misread, so read the criteria bar from top to bottom after each change.
Refining with tags
Tags are a good criterion because they record your own decisions. A rule such as "Tags is Invoice" returns everything you labeled, wherever it lives.
You can combine a tag with other attributes to make a narrow view. For example:
- Tags is Invoice
- Last Modified Date is within the last 90 days
- Kind is PDF Document
This returns recent invoice PDFs and ignores older invoices and other file types.
To match more than one tag, add one Tags rule for each. With "all", a file must carry every tag. With "any", a file needs only one of them.
Using date criteria correctly
Date rules are relative to the moment you open the folder. "Last Modified Date is within last 7 days" shows different files tomorrow than it does today. That is usually what you want, but it surprises people who expect a fixed list.
You can check the same kind of rule from Terminal:
mdfind -onlyin ~/Documents 'kMDItemFSContentChangeDate >= $time.today(-7)'This lists files under Documents modified in the last seven days. If the Terminal result and the smart folder disagree, the rule or the scope in the smart folder differs from your query.
Choose the date attribute that matches your intent:
- Created Date is when the file first appeared on this volume.
- Last Modified Date is when the contents last changed.
- Last Opened Date is when you last opened it. Simply selecting a file does not change it.
Excluding unwanted files
A smart folder often returns clutter, such as items in the Trash, in application bundles, or in system folders. Several tactics reduce this:
- Narrow the scope to one folder instead of This Mac.
- Add a Kind rule to limit results to the file types you want.
- Use a Name rule with the operator "does not contain" to leave out files with certain words.
- Choose a "none" group with the Option-plus method to exclude a tag, for example "none: Tags is Archived".
Files in the Trash do not usually appear in a Finder search scope of a folder, but they can appear under This Mac. Check the scope if you see deleted items.
How an edit flows through the system
The diagram shows what happens when you edit and save a smart folder.
The results always come from the Spotlight index. Editing a rule changes the question, but the index decides which files answer it. If a file has not been indexed, no rule can find it. The later troubleshooting chapter covers that case.
Inspecting the stored criteria
Finder writes the saved query to a file. By default, it is in your Saved Searches folder:
ls ~/Library/Saved\ SearchesYou can print a saved smart folder's property list to see what you changed:
plutil -p ~/Library/Saved\ Searches/Recent\ Documents.savedSearchReplace Recent Documents with the name of your own smart folder. Run the command before and after an edit, and the stored query should differ. If it does not, you probably did not click Save. The next chapters return to these files in more depth.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Edits vanish after closing | Save was not clicked | Reopen, edit, and click Save |
| Too many results | Scope is This Mac, or rules are too loose | Narrow the scope and add Kind or date rules |
| No results | Rules joined by "all" cannot all be true | Remove one rule at a time to find the conflict |
| Tag rule returns nothing | Tag name is misspelled or differs in case from the stored tag | Pick the tag from the value menu instead of typing it |
| Folder shows different files each day | Date rule is relative | Use it deliberately, or use a fixed date range |
A reliable debugging method is to remove all rules except one, check the results, and add the rules back one at a time. The rule that suddenly empties the list is the one to rework.
Summary of practice
- Show the criteria bar through the Action menu and read each rule aloud.
- Save every change you want to keep.
- Set the scope before you add other rules.
- Combine tags with Kind and date rules for precise results.
- Use Option-plus for "any" and "none" groups.
- Test one rule at a time when results look wrong.
Exercise
A smart folder named "Recent Invoices" has the rules Tags is Invoice, Kind is PDF Document, and Last Modified Date is within last 30 days, all joined by "all". You want it to also include Pages documents tagged Invoice. Describe how you would change it, and name one step that makes sure the change is kept.
Show answer
Show the criteria with Action > Show Search Criteria. Hold Option and click the plus button to add a group, and set the group to "any". Place two rules in it: Kind is PDF Document and Kind is Pages Document. Remove the original standalone Kind rule so it does not conflict with the group. The Tags and date rules stay joined by "all". Then click Save at the right end of the criteria bar so the new query is written to the .savedSearch file.
Exercise
You edited a smart folder, but a colleague says the folder looks unchanged when they open your shared copy. You run plutil -p on the .savedSearch file and the old query is still stored. What most likely happened, and what do you do?
Show answer
The edit was never saved, so the file on disk still holds the old query. Reopen the smart folder, show the search criteria, make the change again, and click Save. Then run plutil -p again to confirm the stored query now contains the new rule.