The Windows 7 search dropdown always searches within sub folders, but I only want to search the current folder. How can I do this?
7 Answers
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.
-
3
-
2NVM, the above doesn't work as expected. Perhaps someone can offer a correction? Dec 29, 2014 at 23:47
-
*.zip -folder:".\*" also excludes the current directly (as well as sub-directories). The above example works correctly to only exclude all sub-directories if "Downloads" is the current working directly. Feb 4, 2015 at 16:59
-
1@Xzila Its thanks to the trailing slash, let me give you a simple example, if we have the file "foo.zip", what is its folder? its folder is "C:\Downloads", it is NOT "C:\Downloads\", so when you do "-folder:"Downloads\*" it matches the later but not the former, effectively excluding only subdirectories Aug 27, 2016 at 14:27
-
1unix/Linux users, think carefully, "-folder:" is exclude the matching folder, negating the "folder:" clause. Semantic overload leaking in from the find command strikes again.– BenPenNov 8, 2016 at 20:02
to ignore folders
(not their contained files), then try:
System.Kind:<>folder
-
3
-
The question is about excluding subfolders AND their content. Dec 20, 2022 at 21:38
-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.
-
-
1@NiteCyper, did it work for you in Windows 7? (I am not on Windows, but it seems the parameter is outdated? See the links I added to the answer.)– ArjanDec 14, 2014 at 9:43
-
For future readers: it seems that
System.FileName
can also match directory names, so then maybeSystem.FileName<>name_of_subfolder
would work. Also, System.Kind might allow forSystem.Kind:<>folder
to exclude all folders (or when combined withSystem.FileName
specific folders?). And it seems one might use this long list in search. (But: I am not using Windows.)– ArjanDec 14, 2014 at 9:51 -
@Arjan Yes, I use Windows 7. Windows 7 seems to have automatically removed the colon. Dec 16, 2014 at 0:18
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!
-
1That will NOT do the trick. And that is a rotten glaring DANGEROUS bug in Explorer. Think Search -> Ctrl-A -> Delete. Subfolders are ALWAYS searched from the Explorer search box.– user350381Jul 26, 2014 at 23:08
-
1
-
6This is a permanent change for a casual/ephemeral search, it doesn't make any sense to do this. Dec 16, 2014 at 9:02
*.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.
-
On Windows 8, I was also able to run this from within the directory to be searched. E.g., in
C:\foo
, enter*.zip folder:"\foo"
in the search box. Thanks for the info and link!– cxwSep 1, 2017 at 13:50
In Windows 10 & 11, you can select the option Current Folder
Windows 10:
Windows 11:
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