Exclude sub-folders from Finder search

findersearchspotlight

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.

Best Answer

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.