Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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? –  ؘؘؘؘ 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

 
discard

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.