How To Search Inside Multiple Text Files on Windows

Most of us rely on in built search application to find files and launch programs, but searching for text within files is limited to specific file types or non-existent by default.

If you don’t want to install any third-party software and you are comfortable with the command line, then you should skip to the bottom of this article else we will assume that most people are more comfortable with graphical user interfaces and like using search applications to find their files.

grepWin

grepWin is a simple search and replace tool which can use regular expressions to do its job. This allows to do much more powerful searches and replaces. In case you’re not familiar with regular expressions, here is a very short regular expression tutorial for you.

For more information and download: grepWin.

AstroGrep

AstroGrep is a Microsoft Windows grep utility. Grep is a UNIX command-line program which searches within files for keywords. AstroGrep supports regular expressions, versatile printing options, stores most recently used paths and has a “context” feature which is very nice for looking at source code.

For more information and download: AstroGrep.

dnGrep

dnGrep allows you to search across files with easy-to-read results. Search through text files, Word documents, PDFs, and archives using text, regular expression, XPath, and phonetic queries. dnGrep includes search-and-replace, whole-file preview, right-click search in File Explorer, and much more.

For more information and download: dnGrep.

Using built-in Windows commands to search for keywords

If you don’t want to install a full-fledged program, you can use the built-in command line tools in Windows.

Using FINDSTR coomand to search for strings in files.

Syntax
      FINDSTR string(s) [pathname(s)]
         [/R] [/C:"string"] [/G:StringsFile] [/F:file] [/D:DirList]
            [/A:color] [/OFF[LINE]] [options]

Key
   string      Text to search for.
   pathname(s) The file(s) to search. 
   /C:string   Use string as a literal search string (may include spaces).
   /R          Use string as a regular expression.
   /G:StringsFile  Get search string from a file (/ stands for console).
   /F:file     Get a list of pathname(s) from a file (/ stands for console).
   /d:dirlist  Search a comma-delimited list of directories.
   /A:color    Display filenames in colour (2 hex digits)

options can be any combination of the following switches:
   /I   Case-insensitive search.
   /S   Search subfolders.
   /P   Skip any file that contains non-printable characters
   /OFF[LINE] Do not skip files with the OffLine attribute set.
   /L   Use search string(s) literally.
   /B   Match pattern if at the Beginning of a line.
   /E   Match pattern if at the END of a line.
   /X   Print lines that match exactly.
   /V   Print only lines that do NOT contain a match.
   /N   Print the line number before each line that matches.
   /M   Print only the filename if a file contains a match.
   /O   Print character offset before each matching line.

If more than one file is searched, the results will be prefixed with the filename where the text was found. To learn further you can read the reference document.

scroll to top