1

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

4
  • Can you use this answer to exclude a folder from Spotlight?
    – fsb
    Commented May 17, 2019 at 20:54
  • Ah, I hadn't thought of actually excluding $HOME/Library from the Spotlight index altogether. That would certainly do the job but that does come at the cost of never being able to use Finder search within $HOME/Library for any reason. I suppose I could locate for such things on the CLI. Hmm... Anyway, thanks for that suggestion- worth considering.
    – Darf Nader
    Commented May 17, 2019 at 21:07
  • Why do you find recents folder so useless?
    – Natsfan
    Commented May 18, 2019 at 0:24
  • 1
    For me, neither Spotlight nor Smart Folders show results of files in the user Library. I don't have anything configured to be excluded.
    – benwiggy
    Commented May 30, 2019 at 16:57

1 Answer 1

3

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:

  1. 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.
  2. 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.

6
  • apple.stackexchange.com/questions/173291/… This answer clearly says that path based file exclusion can be done. Then how is your first statement correct ?
    – anki
    Commented May 30, 2019 at 17:20
  • The answer at apple.stackexchange.com/questions/173291/… explains how to exclude folders from Spotlight indexing. This does indeed prevent files from that folder from appearing in search results. Since the folder is no longer indexed, its contents will however not appear in any search. This is not desirable. Commented May 30, 2019 at 19:03
  • The answer at apple.stackexchange.com/questions/173291/… also suggests that the Finder may be able to perform searches without using the Spotlight index. Such searches can only find files by file system attributes like name. Never by content. Commented May 30, 2019 at 19:05
  • @ankii I believe I finally understand the reason for the confusion / misunderstanding. By "Spotlight does not know / care about file paths" I mean that the file path is not an indexed property. As per the other answer, one can exclude folders from Spotlight indexing. In that sense Spotlight does care about file paths. It knows where it is allowed to go: which files and folders to process. Commented Jun 8, 2020 at 13:55
  • yes, the wording is a bit off.. if you correct it, I'll remove my downvote
    – anki
    Commented Jun 8, 2020 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .