I would like to recursively search through a parent directory and all sub directories for several separate strings and show the results for each string. For example:

Text To Search For

(list continues for several hundred words)

Results Pane

  - Found in files x, y, z
  - Found in files x, y
  - Not found in any files
  - Found in files y, z

I have a list of several hundred strings that I will have to search for several times. It is a tedious process to search for individual strings and I'm looking for a way to perform this in a batch process.

Are there any Windows programs that can perform this type of search?

I've tried with notepad++ and Visual Studio, but haven't quite found a way to meet the requirements of showing each string as a separate result.


The below batch script would do this.

@echo off

for /F %%i in (pattern.txt) do (
echo Files containing %%i
findstr /M /C:%%i /S *.txt

For the case of string not present in any of the files, it does not print the statement you wanted. Instead, it prints an empty list of files. source: Findstr command


The Swiss File Knife has a command "hexfind" which can search any number of patterns in parallel. Create a search pattern file "mypatterns.txt" containing:


And to search all files of folder mydir, including all subfolders, type:

sfk hexfind -bylist mypatterns.txt mydir

This will produce a dump of every single hit found, like:

testfiles\Formats\10-dir-list.txt : hit at offset 0x273
>4261724D 75672E68 70700D0A 433A5C73< BarMug.hpp..C:\s 00000273
testfiles\Formats\10-dir-list.txt : hit at offset 0x290
>466F6F42 616E6B5C 42617244 72697665< FooBank\BarDrive 00000290

To list only the filenames containing hits, add option -nodump. This will not produce the exact results pane as you requested, but at least you see where your patterns occur.

If it's a problem to create mypatterns.txt with the // format, you can produce the file from a wordlist.txt like:

sfk filter wordlist.txt -form "/$col1/" +tofile mypatterns.txt
  • Thanks for the suggestion of Swiss File Knife and the great example. – Metro Smurf Jul 13 '12 at 1:44

Grep is your friend. You can put the patterns to look for into a file called patterns.txt and then run something like the following:

grep -f patterns.txt -r * > ..\results.txt


Just came across a question about grep-like things available in Windows. The question and answers cover lots of free and non-free standalone tools and commands built-in to e.g. Powershell.

  • Grep would probably work with a bit of wrestling of the switches. Thanks for the suggestion. – Metro Smurf Jul 13 '12 at 1:45
  • Actually all the switches are shown. '-f filename' is the list of patterns in a file and '-r' is for recursive. The output is very close to what you specified as the goal. The patterns.txt should have a pattern per line. – jpe Jul 13 '12 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.