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

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").

"Findstr is an extremely handy utility, but it has one limitation: it's intended to work on plain text files ..."

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".

C:\Wherever Windows Command Prompt Starts For You> CD C:\t
C:\t> findstr /B Subject *.eml
30BA7C0F-00000001.eml:Subject: Welcome to Windows Mail
30BA7C0F-00000002.eml:Subject: About Lunch next week
30BA7C0F-00000003.eml:Subject: Thanks for the answer!
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.

Text Files versus Other Files

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.

Searching, Searching
image by Tall Chris on Flickr.

Options, We Have Options

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:

C:\t> findstr /?

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.

Article C4559 - November 12, 2010 « »

Share this article with your friends:

Share this article on Facebook Tweet this article Email a link to this article
Leo Leo A. Notenboom has been playing with computers since he was required to take a programming class in 1976. An 18 year career as a programmer at Microsoft soon followed. After "retiring" in 2001, Leo started Ask Leo! in 2003 as a place for answers to common computer and technical questions. More about Leo.

Not what you needed?

7 Comments
sirpaul2
November 16, 2010 9:32 AM

No question is supposed to be stupid, but here goes.
I don't use Hotmail, but can't you just rename those files?

Sure you can rename them. I'm not at all sure how that helps.
Leo
17-Nov-2010

Me
November 16, 2010 11:01 AM

@ sirpaul: You could do that but then the mail program might not be able to find them or it might put up a big fuss. Im not sure about Windows Mail (which is not hotmail) though.

Nick
November 16, 2010 4:14 PM

What's wrong with using the Search facility in Windows Explorer? If you select "All files and folders" there's a place to type in a word or phrase to search for.

Or am i missing something about the question?

I don't believe the the search facility searches the contents of the files, just the file names. (Though there are utilities to do that as well, and they could be used.)
Leo
17-Nov-2010

phil lethes
November 16, 2010 9:33 PM

a program like Copernic will show you the content of files as well as just the file name. I work with people who simply will not name their files clearly, or even keep track of where they put them; Copernic is a god-send to finding "lost" data. It works in the background and will index the entire drive. Free version serves up ads, but still so much better than Google desktop.

Nick
November 17, 2010 10:38 AM

Leo, you can search the file name and a word or phrase in the file. I use it all the time. Click Search button, then on panel on left select "All files and folders" (3rd item down), then you get three input boxes: "All or part of the file name", "A word or phrase in the file", and "Look in". Type what you are looking for in the middle pane and put the root folder in the bottom one. You can use the top one to restrict the file names. The search then lists all the qualifying files that contain the said phrase or word.

John L Brown
November 26, 2010 2:36 AM

Windows Search Deskbar, which routinely indexes files daily, and as well, provides detailed instructions, to search for, or 'within' specific files appears to be a very effective method to locate lost or otherwise required files or their contents. Thanks.

Graham Vine
December 1, 2010 6:08 AM

The only "search" I can find in Win7 is the awful indexing version. I used to use the proper search in XP all the time. Is there a proper search available in Win7?

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.