Using findstr.exe to Parse Text Files – Simple “grep” for Windows

The DOS command findstr.exe can help you …find strings… in text files.

In conjunction with a for loop and tokenization, you can perform actions on the match results.

For example, the following command finds the string “Delivery Status Notification” in all “.eml” files in the current directory and move them to another directory:

for /f "tokens=*" %a in ('findstr /M /L /C:"Delivery Status Notification" *.eml') do move %a C:\temp\moved_emails

Hope this helps!

This entry was posted in Batch Files. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *