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.


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/'
  • 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? – Lri 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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