Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is possible to tell spotlight to search for a folder "x" that is contained within folder "y"?

For example, I have several dirs named "june" in my computer, but one of them is inside a dir named "pictures". This is the one I want to find by using a query such as june dir:pictures.

├── documents
│   └── june
├── downloads
│   └── june
├── june
├── pictures
│   └── june               //I need to find this specific june
├── presentations
│   └── june
└── statements
    └── june

I know it's possible to search in finder or use the find/grep commands for it, but that's out of the scope of this question.

share|improve this question
up vote 2 down vote accepted

I don't know any way to do that from the Spotlight menu, but you could always open the folder in Finder, start a search, and select the folder from the scope bar:

or use mdfind:

mdfind -onlyin ~/Pictures/ june

kMDItemPath cannot be used with mdfind. Otherwise you might use something like 'kMDItemPath=="*pictures*/june/".

However mdfind combined with grep should be as fast as mdfind alone:

mdfind 'kMDItemFSName==june' | grep '/pictures/'
share|improve this answer
Of course. But that is another thing, assuming I know where to look for (in the example, Pictures). I want something broader than that, since I don't know where the file/folder is. Well, looks like is not possible out of the box. – bluefoot Jul 10 '12 at 11:25
Sorry, I edited the answer. Could you just grep the output of mdfind? – user495470 Jul 10 '12 at 11:54
Sure, thanks. I can grep or find it. So the answer is: not possible trough spotlight. – bluefoot Jul 11 '12 at 14:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.