I want to search the pattern only in the file names not in the file content. For content, I can use findstr
but I want to search the filenames for the pattern.
Asked
Active
Viewed 58 times
-1

Mark
- 3,609
- 1
- 22
- 33
1 Answers
0
From directory at which you want to start a search:
dir /s *substring*.*
This will search through all subdirectories (because of '/s' option), starting at the current, searching for all files that have the string 'substring' and an arbitrary extension. Of course this is an example; you can replace *substring*.*
with any other regex.

baske
- 1,316
- 9
- 16
-
You don't need the `.*` at the end in wildcards. `dir /s *substring*` will work fine. – Phylogenesis Apr 22 '14 at 08:44
-
really? I think then it will mean something different.. My current regex will require a file extension (which can then be any extension at all). The results will not include files without extensions in my case.. In other words: your regex will have different results from mine, because they are different :-) Surely both are valid so thanks for that 2nd example. – baske Apr 22 '14 at 08:46
-
1`*substring*.*` will also find files/directories without extensions. – Phylogenesis Apr 22 '14 at 08:50
-
Thanks baske and Phylogenesis. Job completed. – Samarth Srivastava Apr 22 '14 at 08:55
-
@Phylogenesis Thanks for that piece of info. Just checked on my PC with some sample directory/file structure. I was surprised, but indeed, you were absolute correct! – baske Apr 22 '14 at 10:06
-
to omit the directories, use `/a-d` ("A"ttribute "-" "D"irectory) – Stephan Apr 22 '14 at 19:37