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"

16 comments:

  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!
    Thanks!

    ReplyDelete
  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!

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

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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  7. Watch IPL 2018 here. Check IPL live Score at crickspo.com. Watch IPL live? IPL
    Live stream
    available here for free. Watch IPL Final or check ipl live score 2018 or IPL Final Live Stream.

    ReplyDelete
  8. Good one.You shared a valuable information

    ReplyDelete
  9. Your post is very helpful to get some effective tips to reduce weight properly. You have shared various nice photos of the same. I would like to thank you for sharing these tips. Surely I will try this at home. Keep updating more simple tips like this.  Check plagiarism

    ReplyDelete
  10. Windows 10 is the up and coming version of Windows that will be released to the world in the near future. We need Secure Password Generator for saving our personal data or computer security. In this article we are going to take a look at the different versions of window 10 and get strong passwords for accounts.

    ReplyDelete
  11. One of those unfortunate things to forget is your Windows log in password. etcher alternative

    ReplyDelete
  12. Thank you The travelers who travel to Kenya need visas Kenya. That they can apply travel to Kenya from UK online and can get the 24*7 customer assistant.

    ReplyDelete
  13. Good one.You shared a valuable information. If you want to know about access player Locker code Then, I refer you to read our article about NBA 2K21 Locker Code. It gets a Locker code. Plz, read it once.

    ReplyDelete
  14. Thank you.. Get the Azerbaijan electronic visa through online e visa application to travel to Azerbaijan. Just follow 3 steps, fill application, upload document and make online payment for Azerbaijan e visa.

    ReplyDelete
  15. Every online on line casino bonus is distinct, related to|very like} no-download poker machine games. Players can thus experiment with the varied bonus varieties. Another important factor to note is that you might get access to totally different promotions depending on your nation of residence. And not only will the on line casino bonuses be totally different, but the terms & conditions that come connected will also range on your country’s rules. For occasion, gamers from the UK can’t declare any promotions with a bank card and don’t have VIP perks. 솔 카지노 Moreover, UK casinos should guarantee all bonus T&Cs are completely clear and simply accessible to gamers.

    ReplyDelete