45

The Windows 7 search dropdown always searches within sub folders, but I only want to search the current folder. How can I do this?

Worthwelle
  • 4,816

7 Answers7

30

A way to do this (in Windows 7) is to discard all subfolders using -folder: with \*, for example (when searching for .zip files inside the downloads folder):

*.zip -folder:"Downloads\*"


That's all.

Ivan Castellanos
  • 500
  • 1
  • 5
  • 12
9

to ignore folders (not their contained files), then try:

System.Kind:<>folder
T.Todua
  • 4,053
8

-folder:(name_of_subfolder) will exclude "name_of_subfolder" from the search results.

On the Microsoft website, see Advanced Query Syntax for more options (some of which may be outdated), and Advanced tips for searching in Windows which uses a newer syntax such as System.Kind:<>picture, but seems to be less complete.

Arjan
  • 31,511
6

In order to not search in sub-folders, in the search window, click "organize" (upper left corner) and select the option "Folder and search options." In that window, select the "Search" tab. Unselect the the option "Include subfolders in search results..." That will do the trick!

3

In Windows 10 & 11, you can select the option Current Folder

Windows 10:

Windows 10 search in current folder


Windows 11:

Windows 11 search in current folder

3

*.zip folder:"\MyFolder"

This must be run from the parent folder to search MyFolder, but none of MyFolder's sub-folders or sibling folders. The double quotes and the leading backslash appear to be required. I tested this on Windows 7 and it worked. I found this answer here: answers.microsoft.com: how do I NOT search subdirectories

While I found the excluding folder option from another answer worked (thanks), if you have a lot of subfolders to exclude, this option is likely easier.

FreeText
  • 191
1

I'm on a Windows 10 machine, but I doubt whether things have changed. If I'm right the above answers are wrong.

In the search box

If you go:
common*source
... this brings up all files and folders with the substring "common" followed by the substring "source": e.g. commons-collections4-4.0-sources.jar

NB For some unaccountable (Micro$oft) reason, even if you have set the thing NOT to search for file contents in "Advanced options", it will still search the contents of files if you don't precede the search string by "name:" or "filename:"

If you go:
name: common*source
... nothing comes up!

If you go:
filename: common*source
... this brings up all files and folders with the substring "common" followed by the substring "source": e.g. commons-collections4-4.0-sources.jar

If you go:
filename: common
... it will bring up all files and folders which have "common" in their name.

If you go:
filename: common -folder
... it will bring up only files (no folders) with "common" in their name

Note the difference between "name" and "filename". I suspect that in the first case it is using a "property" of the file hidden somewhere, and that most of the time you will want to be searching for "filename".

Also note that use of the wildcard * requires that the part before it precedes the part after it (of course). If you want these substrings to appear in your filename in any order it's a bit tricky. You have to do something like this:

filename: "*test*" AND "*co*" -folder

... which is equivalent to this:

filename: "*co*" AND "*test*" -folder

or indeed this:

filename: "*test*" + "*co*" -folder