Findstr.exe: What Is It & How to Properly Use It

Rediscover search with this powerful command-line tool

Reading time icon 4 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • Finding files that have been renamed or moved from their original location can be difficult, especially if the file types are common and it's a lengthy search.
  • Findstr is a very powerful command line tool that makes it easy to search through files and folders based on criteria missing in the standard File Explorer search.

You already know how powerful the Windows Command Prompt is. You can even customize it. But did you know about its built-in command utility findstr.exe or Find String? Findstr.exe is a command-line utility that can search for strings in files. 

It is used to find a specific string in one or more files. By default, it searches the current directory and all subdirectories. While it can be helpful, it will do you no good if you donโ€™t know how to use it. Lucky for you, we share how to get the most out of it here.

What is the usage of findstr.exe in Windows?

You may be wondering why anyone would use a command-line utility when Windows already has the find feature in File Explorer. While it works most of the time, it can be time-consuming and still not generate the expected results.

The main advantage of using findstr.exe over other text search tools is that it allows you to search inside binary files such as Microsoft Office documents or PDFs. 

In addition, findstr.exe provides options to control what kind of output is displayed and which lines are skipped when searching through large files with thousands of lines.

Other benefits of using findstr.exe include:

  • Supports regular expressions (regex) – Regular expressions allow complex searches that would be much more difficult using other methods such as wildcards or string comparisons. If you were wondering whether you can use regex in cmd, hereโ€™s your answer.
  • Searches binary files – While other search tools only work on text files. Findstr can search both text and binary files. 
  • Readily available – Findstr is not limited to a select Windows version. You can readily find it in older and newer versions of Windows. It also helps that you do not need to download it as it is built-in.
  • Allows case-insensitive searches – You don’t have to worry about capitalization when searching for words. This is one of the most common reasons some searches fail because theyโ€™re case-sensitive.

How to use Findstr in a batch file?

To use Findstr, you must run the Command Prompt with administrative privileges. This way, you can access all the drives on your computer and their folders, and your search wonโ€™t be limited. 

This allows you to run commands that search through every folder on your hard drive. Before you embark on your search, you must know how the findstr commands work and when to use them.

Below are some of the common parameters:

  • /B – Matches pattern if at the beginning of a line.
  • /C – Search for strings containing the specified substring.
  • /S – Searches in the current directory and all subdirectories.
  • /I – Ignores uppercase and lowercase distinctions when searching for patterns. Also known as the Case-sensitive search.
  • /L – Lists only file names, not contents.
  • /R – Use regular expressions in strings.
  • /M – Print only matched file names.

To test a few examples:

1. Use case-insensitive parameters

  1. Hit the Windows key, type cmd in the search bar, and click Run as administrator.cmd-run-admin-w11 unexpected kernel mode trap windows 11
  2. Weโ€™re going to test out the case-insensitive string. Type the following command and hit Enter: findstr /s /i nba โ€œ.โ€
  3. In context, the term nba in the text is in caps, but with the /I command, it will search irrespective of the case, meaning that upper and lowercase characters are considered equal. The /s command will search in folders and sub folders while the โ€œ.โ€ command specifies that the string should search each file and not limit to only text files.

2. Search for specific text

  1. Still in the Command Prompt window, type in the following command and hit Enter: findstr /c:"nba" kwame.txt
  2. In the command above, you have now refined your search only to locate the term nba and in the specific document named kwame.

3. Search files in a specific location

  1. Still in the Command Prompt window, type in the following command and hit Enter: findstr /c:"nba" y.z
  2. Here, you are searching for NBA in a specific location which is y and z in this case.

From the examples above, it is easy to see that Findstr.exe is a great resource when you want to search on your computer that you’ve never done before. It’s extremely useful but requires a specific syntax to know how to use it properly.

Hopefully, this little introduction to findstr.exe brings you a step closer to using it as part of your regular toolkit and taking advantage of all it offers.

Speaking of command-line utilities, we also have an awesome beginner guide on all things try-catch command, so be sure to check that out too.

Let us know how you will use this command-line in the comment section below.

More about the topics: Windows 11