El comando findtr ms-dos no buscará subdirectorios

I had to switch off my windows search indexing in Windows 7 as the old hard disk was constantly making noise with indexing switched on!

Ahora quiero usar Windows command prompt to search for a specific text term within all files located within the current directory and sub directories

How do I use the Windiows command findstr to search subdirectories?

Currently, when I open a command prompt and change directory to C:\Users\Damien\Documents\Research\2012July y ejecuta el comando findstr "thesis" *.tex /S, Obtuve el siguiente error :

FINDSTR: Cannot open /s

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

preguntado el 01 de febrero de 12 a las 14:02

Posting as comment, since I know this isn't the answer you want, but: install Cygwin (www.cygwin.org) and you'll have a full set of consistent, functional, well-documented command-line tools that always just work. The UNIX find command is infinitely more flexible and powerful -- and of course can do what you want here. -

2 Respuestas

Necesitas poner /S at the beginning, i.e.:

findstr /S "thesis" *.tex

From the built in 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 are called, need to come antes de your pattern/string

Respondido el 08 de junio de 16 a las 13:06

@Jon How would I structure the syntax if I also want to indicate the path (i.e. findstr /S "some_string" *.txt PATH?) where and how would I indicate the path for the folder with the sub-folders I want to search. Thank you - IberoMedia

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

findstr /S "thesis" *.tex

Respondido el 08 de junio de 16 a las 14:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.