findstr to find multiple strings in multiple files
top of page

findstr to find multiple strings in multiple files


As discussed on this blog in the past, the Windows command findstr can be used to perform complicated searches through multiple files, including regular expression searches. Here's a quick demo of how findstr can be used to search for multiple search terms in multiple files.

Compose a batch file with this code:

@echo off

for /F %%i in (searchlist.txt) do ( echo Files containing %%i findstr /C:%%i /S *.txt )

[Enter this in a text file and then save it with the extension 'bat'. ]

'searchlist.txt' refers to a file listing the strings you want to search for. Each string needs to be on a separate line.

The end of the code [*.txt] specifies that only .txt files should be searched.

The result shows the hits in context for each file, one search term at a time:

Files containing court frankenstein.txt:courtyard belonging to the house which I inhabited, where I remaine frankenstein.txt:of the court, which had that night been my asylum, and I issued int frankenstein.txt:as witnesses, I accompanied them to the court. During the whole of frankenstein.txt:court she threw her eyes round it and quickly discovered where we w frankenstein.txt:his neck, a murmur of horror and indignation filled the court. frankenstein.txt:the court. frankenstein.txt:I rushed out of the court in agony. The tortures of the accused di frankenstein.txt:the court; my lips and throat were parched. I dared not ask the fa frankenstein.txt:court. He made, at that moment, a solemn vow to deliver him and th frankenstein.txt:town where the court was held. Mr. Kirwin charged himself with eve frankenstein.txt:brought before the court that decides on life and death. The grand mobydick.txt:sanctity, that I could not suspect him of courting notoriety by any mobydick.txt:to him who, in this world, courts not dishonor! Woe to him who would mobydick.txt:has proved but hollow courtesy. I drew my bench near him, and made some mobydick.txt:Babylon; and to have been Belshazzar, not haughtily but courteously, mobydick.txt:the shipΓÇÖs cabin belongs to them; and that it is by courtesy alone th

. . . and so on.

Thanks to Srini for the code.


Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

​

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

​

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page