Monday, March 08, 2010

Using the Windows Findstr Command to Find Text, Files and Folders

Currently, I like the findstr command better than other ways to search files in Windows.

Prerequisite: Open Command Window Here
For XP, it's part of Microsoft PowerToys for Windows XP.

For Vista and Windows 7, apparently you hold down the hold down the shift key and right click.

Finding File Contents
Once you have a command window open at the directory you want to search within, you  can do something like this, which will return all lines containing "MyText" in all subdirectories of the current one, case-insensitive, and only searching files that contain printable characters:

findstr /s /i /p "MyText" *.*

It turns out that "MyText" is treated as a regular expression, which is great. But if you don't want it treated as a regular expression, you can use the /l or /c: options.

Finding File & Folder Names
Instead of giving findstr files to search, you can pipe text to it from another command, so to search for file or folder names, you can give it the results of the dir command to search:

dir /s /b | findstr /i "MyFileName.txt"

Combining the Two
Say you want to find all the lines containing "MyText", except you don't want those that are part of a subversion directory. You can do this, where the /v option means only return lines that don't match:

findstr /s /i /p "MyText" *.* | findstr /v /l ".svn"


  1. Hello,

    This was a post that really came in handy. I was having problems with a link in my blog footer and I could not find out which page the code was located on. After opening DOS and following your instructions, the most annoying problem was solved!

  2. Great post. I was having a hard time getting this to work on my own with the lackluster instructions available on other sites. Thank you!

  3. There has been possible instances and the values for the students mentioned in detail and these are almost allowing them to proceed further.

  4. Getting problem to update the latest version- Windows 10 had got significant update in November itself but many could not update it.

  5. Due to which users were unable to understand the windows 10 upgraded problems in the first place and think how to solve them? kmspico

  6. I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.. Search Bar Firefox 57 Quantum addon