Helping people with computers... one answer at a time.
Windows includes a utility that will search through a collection of files for a specified string. That's often a quick way to find the file you want.
Recently, I needed to recover an email that had been permanently deleted from Windows Mail and managed to do so from a C:\ drive backup. However, because of the obscure nature of the email file names (e.g. 61712BF9-00000413.eml), I had to open them, one by one, until I found the wanted one. Is there a quicker way and can these file names be decoded then to make them more understandable?
Yes, there is a quicker way.
No, there's no way that I know of to make those filenames more meaningful.
What we need is a quick way to scan inside of those files. Fortunately, Windows has a way.
One of the improvements that Windows Mail made over the older Outlook Express is that emails are stored in individual files on your hard disk. That makes what we're about to do much easier.
I need to introduce you to a command-line tool.
Findstr, for find string, is a tool that searches files for strings or sequences of characters. (Linux & Mac folks will recognize it as similar to the program "grep").
For example, you can use Findstr to show you all the files in a folder that contain the word "lenticular".
Or files that have lines that begin with the word "Subject".
Let's see how that's done.
The general syntax for Findstr is "Findstr string files" where:
string - is the string you're searching for
files - are the files to be searched
Fire up a Windows Command prompt, and "CD" to the folder that contains the files you wish to search. In this example I'll assume all the ".eml" files are in the folder "C:\t".
I've added the "/B" option (the "Begins with" option), and Findstr is showing me the filename and the matching line from all the ".eml" files that begin with the word "Subject". Since these are all email files in text format, it's showing me the filename and the Subject of the email contained within it.
That alone may be enough for you to identify the email you're looking for. If not, try removing the "/B" looking for other things that might occur anywhere: a unique word you know is in the body, an email address that might help narrow it down, and so on. If you have hundreds of email files, as many of us might, using this to quickly narrow it down to a smaller set to investigate further save a lot of time.
Sometimes it'll be all you need.
Findstr is an extremely handy utility, but it has one limitation: it's intended to work on plain text files; files that contain primarily only letters, numbers and a fairly limited number of symbols arranged as readable text.
You can use Findstr on other files, if you like, but the results will be ... unpredictable.
Microsoft Word documents are most certainly not text files, but it might be enough for you to know that of the 100 Word documents in a folder only these two contain the word "frenetic". (You may want to turn off your speaker, however, since one character, when displayed, actually causes a beep. Better to use the "/M" option which prevents the matching line from being displayed and only prints the filename within which it was found.)
Even some text files may be somewhat confusing. For example, web pages are in fact text files, but they contain a lot of extra information that you normally don't see when they're displayed in a browser. Regardless, once again just knowing that this file contains that string can be very helpful.
image by Tall Chris on Flickr.
Findstr has many, many options to help you search files for strings. I was going to list them all here, but there are too many. Instead:
Will list all the options and give you some basic information on some of the syntax you can use for advanced searching.
One important option that I will mention is the "/I" option to search without regard to case.
In case-sensitive search the words "Subject" and "subject" are not the same - the case of the first letter is different. In a case-insensitive search, they're they same as upper/lower case is not taken into account.
Comments on this entry are closed.
If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.
If you don't find your answer, head out to http://askleo.com/ask to ask your question.