Spotlight: Cannot create a smart folder combining the contents of several folders

Posted by Pierre Igot in: Macintosh
June 16th, 2005 • 6:32 am

I find it hard to believe that such a simple application of the “smart folder” concept has not been included in the Finder in Mac OS X. What I am trying to do is very simple. I want a smart folder that displays the combined contents of several existing folders.

In other words, I want a smart folder with the criteria “file is in folder AORfile is in folder BORfile is in folder C” etc.

Surely something so simple can be achieved in Mac OS X 10.4’s Finder? I am afraid not.

For one thing, there doesn’t seem to be an attribute for this. The default list of attributes is “Kind“, “Last Opened“, “Last Modified“, “Created“, “Keywords“, “Color Label“, “Name“, “Contents“, and “Size“. There is no “Enclosing Folder” or “File Path” here.

If you look under “Other…” to see the full list of available attributes, you’ll find two attributes that sound like they might work. One is called “File pathname” and the other one is called “Whereform“. But I tried both of them, and they don’t seem to work. In other words, I tried to define a smart folder containing files whose “File pathname” contains a specific text string, and it didn’t work. I tried to define a smart folder containing files whose “Whereform” contains a specific text string, and it didn’t work. In both cases, I got 0 results, even though I should have had tons of results.

Then there is the fact that there is no easy way to combine multiple criteria with the OR logical link between them. As we’ve seen before, the only way to do this in the Finder is to use a raw query.

So I tried to find out whether I could achieve this with a raw query. The raw query syntax lets you use OR as the logical link between criteria (with “||“) — but then I was not able to find a “kMDItem“-type attribute that would contain the full file path or the enclosing folder of the file in question. As far as I can tell, such a thing does not exist either.

Basically I am stumped. Achieving the exact same thing in Mail 2.0 is unbelievably easy. You just create a smart mailbox that contains messages which match “any” of the following conditions and then you use conditions of the kind “Message is in mailbox“. Et voilà!

Not only does Mail 2.0 feature proper support for boolean logic in its user interface (without requiring the use of a raw query), but it also includes an “is in” condition!

Why can’t the Finder include such obvious features?

10 Responses to “Spotlight: Cannot create a smart folder combining the contents of several folders”

  1. ssp says:

    I ran into the same problem almost immediately as this is something you’ll want to do rather frequently. Looking at Spotlight’s output strongly suggests that searches for the kMDItemPath property simply don’t work as you’ll never get any results for it, regardless what you’re searching for.

    I’ve filed this as a bug report and it was immediately marked as duplicate, so I suppose the problem is known.

    I suppose that Mail does its own bit of trickery for matching the mailboxes (and not too well, I might add, as filtering on a folder basis won’t surve renaming of the folder).

  2. Pierre Igot says:

    Actually, I’ve since found this PDF document, which describes the various metadata attributes, and, for


    , it says: “Complete path to the file. This value of this attribute can be retrieved, but can’t be used in a query.”

    So the problem is more than “known”. It’s a deliberate decision.

  3. ssp says:

    Argh! That sucks.

    I’m pretty sure this is an ‘improvement’ that came with XCode 2.1. The document has a June changed date. At least it clarifies the situation and Apple will say it ‘closes’ the bug…

    But it renders Spotlight even less useful.

    I thought about making a ‘recent’ smart folder that displays all files on my computer which have been changed in the past days with the exception of those whose path contains Cache or Icons (and likely a few others). As those folders seem to be generously and inconsistently spread around the system, I thought such an approach would be more efficient than figuring out the relevant folders for each application. This looks like a rather obvious thing to do which the full path would be very useful for to save you a whole lot of work.

  4. ssp says:

    Strangely the path can still be inserted into smart folders via the Finder’s UI. Buggy pos.

    300 seconds are very long.

  5. Pierre Igot says:

    What do you mean, the path can be inserted into smart folders via the Finder’s UI?

  6. ssp says:

    You can still build smart folders that search for kMDItemPath stuff using the Finder smart folder UI (i.e. not a raw query) although, according to the new documentation, this isn’t possible.

  7. Pierre Igot says:

    That’s correct, you can do it using the “File pathname” attribute. The problem is that it returns 0 results :).

  8. Paul Ingraham says:

    Any changes in this since June? After upgrading to Tiger recently, I just got around to exploring Spotlight… and almost immediately ran smack into this bug or limitation or whatever it is. The first smart folder I wanted to create was the simplest possible thing I could think of: recently changed files in a specific folder. Can’t do it. No way to search for items in a folder.

    Bad first impression.

    Unable to believe this could possibly be a problem, I spent the last half hour trying to figure out why I couldn’t get any results searching for a text string in a pathname. I guess I still don’t know… but at least I know I’m not the only one and I can stop trying now.

    Since selecting items from a specific folder would probably be essential to at least half or two thirds of the smart folders I might dream up, I guess I need Spotlight like a fish needs a bicycle.

  9. Pierre Igot says:

    Paul: Recently changed items in a folder is done by putting the focus of the search on the folder in question first. The row of buttons at the top lets you select the focus of the search. Click on “Other…” and select the folder you want. Then edit your search criterion (date modified…). Then save as a smart folder.

    The pathname attribute still doesn’t work right as far as I know.

  10. Paul Ingraham says:

    Ah. Well, that’s kind of clunky, but at least it works. Thanks, Pierre.

Leave a Reply

Comments are closed.