7

How can I force Finder to only search the current folder, ignoring the contents of all the sub-folders?
I don't want to exclude the sub-folders permanently from Spotlight, just for a certain search.

The reason I want to do this is that I sometimes have a folder with sub-folders that contain files/folders that are identically named. A simplified example is shown below:

main
|
|-config.txt
|
|-folder 1
|  |
|  |-config.txt
|
|-folder 2
   |
   |-config.txt

When I'm in main and hit CMD+F and type config.txt I get three files. I don't want to click every file to see which one is in main and which in another folder, so ideally the sub-folders wouldn't show up in this search.

  • Interesting question, wonder why ! – Ruskes Jul 28 '13 at 18:07
  • I've been wondering the same thing. Cmd-option-f gives access to some more search options but excluding subfolders doesn't seem available. – Neil Neyman Jul 29 '13 at 2:29
  • Very surprised that all the answers here involve using something other than Finder. Is there really no way to do this from within Finder?! – Wowfunhappy Nov 2 '18 at 0:32
2

Use Unix find as follows

find . -maxdepth 1 -name config.txt -print

In Terminal, type man find for details.

If you do this often, you can make it into a shell function.

  • This was far easier than messing around with the Finder – jcollum Dec 26 '18 at 18:43
3
  1. There is a product called Path Finder 6 that offers a feature called "filters and selections," demonstrated here.

  2. You could try selecting all the items in the folder you are searching and applying a Label, then perform a Spotlight search for your item "AND" the additional criteria of "file label" by holding down the option key while clicking on the plus sign.

  • Point number 2 is actually the answer. Too bad we need to dance around and there's no way to simply check a box for this. Would actually make a search very simple (not deep/recursive). – bauerMusic Apr 7 '18 at 7:25
0

Possible workaround, although this doesn't really answer the question. Not sure if there's a built-in option for this.

  1. In list view, make sure all folders are collapsed --cmd-a (select all) and command-left-arrow are shortcuts for this.

  2. Without selecting the search box or using cmd-f, begin typing the name of the file "config.txt" and this will select that file in your current directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .