[ACCEPTED]-How do I (recursively) search ALL file contents in Windows 7?-recursion

Accepted answer
Score: 44

"user3245549" is right:

All of the above 10 answers with "for loops" and nested bat 9 files are mumbo jumbo. All you need is to 8 just use "findstr" - example:

C:\temp> findstr /S /C:"/work" * | more   <-- this will find the string "/work" in any file


C:\temp> findstr /S /C:"/work" "*.*" | more 


C:\temp> findstr /S /C:"/work" * > results.txt


C:\temp> findstr /S /C:"/work" "*.*" > results.txt

NOTE: You 7 can leave out the "double-quotes" around 6 the asterisks - I just put those because 5 the editor here on Stackoverflow was stripping 4 out the asterisks on either side of the 3 period. NOTE ALSO: You still need the quotes 2 around the "string text" for which you are 1 searching, as far as I know.

Score: 38

If you are looking for a GUI-based solution 7 where you don't have to remember the syntax, try 6 out Notepad++. There is a Search menu which 5 lets you search files in a directory (find 4 in files), limit it to certain extensions 3 (filter), and look in subfolders, and then 2 you just click on the item in the list and 1 it opens that file for edit.

Score: 8

Use the findstr command from a command prompt 2 window.

/s give you a recursive search

/i 1 ignores case

Score: 5

Here is my three file DOS solution, but I am still 25 looking for a proper Windows 7 solution 24 if anyone has one:

1. search.bat

@ECHO off
FOR /r %%a IN (*.*) DO CALL process.bat %%a

Searches all files recursively, and 23 runs process.bat on each one.

2. process.bat

ECHO "%1" >> output.txt
TYPE "%1" | FINDSTR /i "search_string_here" >> output.txt

Prints out the name of 22 each file, in quotes because some files 21 will break the batch file code without, then 20 finds the search string, search_string_here, and prints out 19 the entire line that the search string is 18 found in.

3. output.txt (sample output)

Contains the output, formatted 17 as follows, searching search_string_here in my project_name Java project 16 stored in D:\project_name\, displaying all files searched 15 as well as results if there are some:


Above 14 you can see that search_string_here was found, full line being 13 <name>search_string_here</name>, in D:\project_name\.project file... among other results.

Again, I 12 am still looking for a proper Windows 7 11 solution if anyone has one.

Warning: "Line is too long" Errors; FINDSTR may be buggy:

Apparently, FINDSTR 10 < grep, as if you didn't know. Here's 9 an article that dives into the error in 8 FINDSTR that are do not reproduce when the 7 same input is used in a different file:

Obviously, “line 6 is too long” is a catch-all message for 5 a number of different errors. FINDSTR 4 has some issues. Some time ago, I said 3 that FINDSTR was marginally useful. After 2 today, I’d say it’s even less useful than 1 I thought it was then. - http://blog.mischel.com/2008/10/14/copying-large-files-on-windows/

Score: 4

This can be done through the command prompt, though 2 the syntax is quite verbose

for /r %a in (\*.*) do find "search_text" %a

This now works 1 in Windows 7 (extra dot removed)

Score: 0

If you're looking for a file or folder located 27 in a common folder (such as Documents or 26 Pictures), you can often find it fastest 25 by using the Search box at the top of the 24 folder window. For more information, see 23 Use the Search box.Here.

If you're looking for 22 a program, a website in your browser history, or 21 a file that you've stored anywhere in your 20 personal folder, you can use the Search 19 box at the bottom of the Start menu. For 18 more information, see Find a file or folder.Here.

If 17 you're looking for several related files, such 16 as all the files from a particular month, or 15 all the documents that you have written, you 14 can use the headings above the file list 13 to filter, stack, or group your files. Organizing 12 your files in one of these ways makes them 11 easier to locate and select. For more information, see 10 Use file list headings.Here

When you need to 9 build a search with multiple filters, or 8 when you're looking for files from several 7 folders at once, create your search in the 6 Search folder. When you are done, you can 5 save the search criteria, and use it in 4 the future to find the same set of files 3 again with a single click. For more information, see 2 Create an advanced search in the Search 1 folder.Here

More Related questions