Spotlight: Cannot create a smart folder combining the contents of several folders
Posted by Pierre Igot in: MacintoshJune 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 A” OR
“file is in folder B” OR
“file 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?
June 16th, 2005 at Jun 16, 05 | 6:32 pm
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).
June 16th, 2005 at Jun 16, 05 | 10:00 pm
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.
June 16th, 2005 at Jun 16, 05 | 10:40 pm
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.
June 16th, 2005 at Jun 16, 05 | 10:51 pm
Strangely the path can still be inserted into smart folders via the Finder’s UI. Buggy pos.
300 seconds are very long.
June 17th, 2005 at Jun 17, 05 | 12:31 am
What do you mean, the path can be inserted into smart folders via the Finder’s UI?
June 17th, 2005 at Jun 17, 05 | 12:41 am
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.
June 17th, 2005 at Jun 17, 05 | 4:13 am
That’s correct, you can do it using the “File pathname” attribute. The problem is that it returns 0 results :).
December 18th, 2005 at Dec 18, 05 | 2:19 pm
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.
December 18th, 2005 at Dec 18, 05 | 2:40 pm
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.
December 23rd, 2005 at Dec 23, 05 | 11:45 am
Ah. Well, that’s kind of clunky, but at least it works. Thanks, Pierre.