Findstr ms-dos command will not search subdirectories

I had to turn off Windows Search indexing in Windows 7 because the old hard drive was constantly noisy with indexing enabled!

Now I want to use the Windows command line to search for a specific text term in all files located in the current directory and subdirectories

How to use the Windiows findstr command to find subdirectories?

Currently, when I open a command prompt and change the directory to C:\Users\Damien\Documents\Research\2012July and run the findstr "thesis" *.tex /S , I get the following error:

 FINDSTR: Cannot open /s 

This command will search for the current directory if I delete / S, but I also want to be able to search for text in subfolders.

+7
source share
2 answers

You need to put /S at the beginning, that is:

 findstr /S "thesis" *.tex 

From the on-line help:

 C:\>findstr /? Searches for strings in files. FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file] [/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]] strings [[drive:][path]filename[ ...]] 

Your modifiers / switches, whatever they call, should come before your pattern / line

+16
source

You have your arguments in the wrong order, try the following:

 findstr /S "thesis" *.tex 
+3
source

All Articles