In Search/Spotlight, can you exclude files within $HOME/Library?
I am trying to make some Smart Folders to compensate for the woefully useless Recents folder but I am having some problems trying to filter out things I don't want to appear.
One of them is excluding anything that is anywhere within the $HOME/Library
directory or some approximation of that. I looked into the additional file attributes that are usable as search criteria that can be used in making a Smart Folder (in other words, the list that comes up when you click "other" in the search criteria menu) for things like "path", "has parent directory", or anything similar which would indicate the file/folder is buried in $HOME/Library
somewhere. "Name" only pertains to actual file name and "Document Container" only pertains to the immediate parent directory. I cannot find any attribute whatsoever which might have the full path shown.
Is there a work-around for this, or perhaps, is there a file attribute that has this info that I am simply not seeing that is available?
Anyone know iff
Solution 1:
Spotlight does not index file paths as a property of a file. Thus you can't search for files by path. You also can't ask it to find or exclude files by their parent folder.
You thus need to resort to a two-step process:
- Run a search against the Spotlight index. You can do so at the
command line using the
mdfind
command Filter the results to hide those in your Library folder. - You could use the
grep
command. Alternatively, you can paste the results from mdfind in a spreadsheet and use that to filter the list.
You can get the results you want using the HoudahSpot application. This has the option to specify more than one search location and to exclude locations. HoudahSpot also has an option to filter search results by path. Here you can apply regular expressions.
HoudahSpot can save searches as Finder "Smart Folders". Since the feature you are after is not supported by Finder, the restriction on locations and filters will however be lost in the process.
HoudahSpot has a concept of "Templates" that you can use to much of the same effect as "Smart Folders".
Full disclosure: HoudahSpot is a commercial product of which I am the developer.