How to search inside files on Windows 7?

253

77

In Windows XP we can search for files that contain a defined keyword (inside all files types).

Windows 7 can look inside files for a keyword, but only for text files. (*.doc, *.txt, *.inf, ...), not (*.conf, *.dat, *.*, ...).

Microsoft search filters don't contain any filter I can use for this.

How is this possible?

user8228

Posted 2009-10-25T02:02:48.630

Reputation:

2

Most of the answers below are useless and do not address the question that had been asked. The problem that the OP clearly explained was that Windows Vista+ do not search the contents of certain file types (read file extensions). As they clearly said, some work while others do not. For example, it will find .txt file that contain a word, but not .cpp, .cfg, .php, or even .ini files even though they are all plain-text (and .ini files are even standard to Windows!) This problem still exists and the simplest solution seems to be this answer.

– Synetech – 2015-11-17T19:14:17.347

1MS Visual Studio has a great "find in files" function. No setup - just specify the criteria for more or less instant results. Why this is not in Windows Explorer as an "Advanced" option is beyond me. – omatai – 2018-03-20T03:42:51.343

Answers

131

To get to the Indexing Options:

Start --> Control Panel --> Indexing Options

See Change advanced indexing options for more information.

If you click on the Advanced button in Indexing Options and go to the File Types tab, you will get a list of file types and the way they are indexed. For the file types you want, you can specify that you want the file contents indexed, and not just the file properties.

Or you can just do a normal search, and after the search is finished you can click on the "File Contents" button under the "Search again in" field (which is located after the end of the search results list, if you scroll to the bottom).

Based on this page, the "File Contents" option won't always show up - only when the folder being searched is not marked for file content indexing; in that case, file contents are supposedly searched automatically, without having to specify this option explicitly.

Nikhil

Posted 2009-10-25T02:02:48.630

Reputation: 2 347

1@HaydnWVN it should check non-indexed locations. Seans answer doesn't work for some people either... – jiggunjer – 2015-06-23T11:41:29.750

I don’t use the indexer, so this does NOT fix anything. – Synetech – 2015-11-17T18:22:44.460

1Using Powershell (I like because I can use full regex): Get-ChildItem -recurse *.config | Select-String -pattern "mystring" | group path | select name – drizin – 2017-02-15T16:42:27.840

Created a short video to demo how to apply the solution in this answer http://bit.ly/2p15Ipp

– Ron Harlev – 2017-04-20T23:11:24.283

Far too complicated. Windows Explorer needs an "Advanced" button which hooks to the "Find in Files" function already available in MS Visual Studio. No setup, just immediate results. – omatai – 2018-03-20T03:40:44.753

3@Revolter, do you mean the command-line command FIND? That only searches for a string in a single, specified file; it does not list files that contain said string. – Synetech – 2011-01-21T22:34:57.907

4@Synetech inc. - you can pipe the results of another command into find, so there's no reason you couldn't run it on the entirety of the hard drive (maybe using an attrib search) – warren – 2011-03-22T13:08:04.790

8@Synetechinc. You can say: find "word" * – Oscar Mederos – 2011-05-17T07:12:15.373

1Hmm, I guess using computers since the old days has the distinct disadvantage that it becomes harder to learn about the updates to old commands unless you purposely do so. (It’s not the first time that I’ve learned of new functionality to an old DOS command long after everyone else, including people who learned them in Windows. :-|) – Synetech – 2011-05-17T17:42:59.253

5@nikhil: Unfortunately you don't mention how to get to Indexing Options, nor does the page you link to. – Steve – 2011-07-12T10:49:49.067

3@Steve it's an item in the Control Panel. You can also find it by typing it in the search field on the Start menu. – None – 2011-08-01T19:00:42.563

1@Nikhil, is there a way to search within files in unindexed locations as well? – Shimmy – 2011-12-12T01:32:36.850

8

-1 as it doesn't search in non-indexed locations, even when the option is selected. @Shimmy Sean's answer below does.

– HaydnWVN – 2012-01-19T13:30:17.707

19Or maybe by using the the FIND command instead. – None – 2009-10-25T12:10:08.577

113

I've always gotten better performance when searching inside files by using a GREP tool. I'm a fan of AstroGrep.

twlichty

Posted 2009-10-25T02:02:48.630

Reputation: 1 302

1Awesome tool! Thank you! The Windows search within files is piece of..., well you know. This tool is super fast on my SAS drive and works flawlessly. Found over 200 files where the windows search within contents found only 12 and didn't display what I've been searching for, but I knew what I search and I was certain for the directory. Should I say more?

Thanks again! – GTodorov – 2015-04-11T00:46:35.907

1+1 for AstroGREP and +1 for AgentRansack... +1 also for Cygwin grep command line tool... – ZEE – 2015-11-11T13:42:59.873

Tried AstroGrep and it seems nice, but I needed to find text inside MS Word files with extension .docx, and it seems to exclude these by default. With no way to override! – Cyberherbalist – 2016-05-30T18:29:05.943

1Wow!! this one is good! – Rodniko – 2012-04-22T15:19:47.840

4Also a plug here for Agent Ransack. Shell integrated, small and fast, supports regex as well. – ingredient_15939 – 2013-03-08T05:23:01.290

12AstroGrep is lean & mean. 80k, lightning fast, & searches network locations. Thanks for the heads up on this tool. – Sean O – 2009-11-30T16:39:40.540

grepWin is a similarly lightweight grep tool for Windows that has different options from AstroGrep that are useful in some situations. – kevinmicke – 2014-03-11T23:47:48.923

84

I believe you can also just enter "content:blahblah" in the search filter box in upper right corner of Windows Explorer. This works at least for Text files and Office documents. It also works for source files.

Sean Sexton

Posted 2009-10-25T02:02:48.630

Reputation: 973

2The "content:blahblah" tip worked well for me. We've got a folder containing a bunch of SQL queries and we're constantly using Notepad++ to search the contents of that directory for certain keywords, table names, etc. This search keyword eliminates the need for that step. [Note: it was the singular form — content vs. contents — that worked for me in Windows 10.] – Jason H. – 2014-10-03T19:25:04.543

3It seems to work for html, js, css, xml, sql, but unfortunately not php. – kcdwayne – 2015-02-25T14:26:55.443

1The field is irrelevant, both content: and contents: work, but only on certain file types like .txt and .html. The problem is that it does NOT work for other types of plain-text files like .cpp, .php, .cfg, or for that matter, even .ini which is type that comes with Windows. – Synetech – 2015-11-17T18:16:16.763

This only works with a few predefined file types. I does not work with .tex files, which I'm sure have been known as easy to search through, text-only files for decades. It's not even possible to force the search to look at these files (*.tex content:begin), quite ridiculous. – mafu – 2016-09-28T11:12:10.047

19Doesn't seem to work – ThomasMcLeod – 2011-05-31T04:35:52.603

@ThomasMcLeod working to me, maybe you need the "searching in nonindexed files" – Avram – 2011-06-10T19:27:21.693

1For Windows 7 it looks like it's content: not contents: – Jeff – 2011-08-17T19:49:44.637

17I found that it is also localized, in German for example inhalt: – mjustin – 2011-10-13T08:36:00.617

3'contents:$$$' where $$$ is the content i'm looking for works for me in Windows 7 – HaydnWVN – 2012-01-19T13:29:11.640

2It looks like SP1 ignores content: and contents: now, even though it still turns blue; instead you have to click File Contents at the bottom of the search results. – SilverbackNet – 2012-05-16T23:22:24.190

4Doesn't work in Windows 7 32 bit. I copied and pasted from a file in the directory being searched and it said that string wasn't found. – weberc2 – 2012-10-26T13:52:53.453

56

You can play with findstr.

findstr /s /m searchstring *.*

Options description:

/S         Searches for matching files in the current directory and all subdirectories.
/M         Prints only the filename if a file contains a match.

jet

Posted 2009-10-25T02:02:48.630

Reputation: 2 675

@Synetech Why not? It's very easy to use, e.g. findstr "todo" *.txt. – mafu – 2016-09-28T11:17:56.950

/i for case insensitivity is also potentially very valuable.

FINDSTR is the only, ONLY non third party way I have found to search for PARTIAL strings. If you search for

goog

it will match google.com or 123779goog44682 or 123google.com55

and to my knowledge there is NO way the Windows folder/Explorer "search box" or Control-F can perform that very, very simple, logical task. Speaking after decades of high end C and Assembler computer development work, laugh or mock all you want, but I state to you: imbecilic Microsoft designers do not understand computers. – MicrosoftShouldBeKickedInNuts – 2018-10-05T08:51:45.537

16

Notepad++ can do this and is free. Find in files is CTRL-SHIFT-F.

Rob Sedgwick

Posted 2009-10-25T02:02:48.630

Reputation: 444

14

Agent Ransack is always worth a look. It's free, fast, good reputation, and doesn't use indexing.

snowdude

Posted 2009-10-25T02:02:48.630

Reputation: 2 560

Note - I had been using AR but there are some licensing restrictions about personal vs business use. Overall though the tool works really well and give the kind of file search focus one needs. – John M – 2016-03-11T04:31:52.817

9

In Windows Explorer, menu Tools -> Folder Options:

Press on the search tab and here, the first option: what to search, choose to search for non-indexed files inside the file.

user33873

Posted 2009-10-25T02:02:48.630

Reputation:

Not using the indexer, so this does not fix the problem. – Synetech – 2015-11-17T18:16:42.850

This seemed to ignore the option, because my file type was configured in the Index Options to not be treated as a text file. A .properties file does not get searched for text by default. – Richard Le Mesurier – 2012-10-31T11:32:09.257

1This was the only answer on this page that worked for me. I had to check the "Don't use the index when searching..." option, too. – Fuhrmanator – 2013-05-01T13:20:05.370

8

Windows 7 still has the ability to search for strings inside files everywhere (and not in indexed locations).

In Windows Explorer, go to menu Tools/Folder options and select "Always search file names and contents".

Probably the file types still have to be set up correctly in Advanced Options of Indexing Options".

Gunter Spranz

Posted 2009-10-25T02:02:48.630

Reputation: 89

Odd that indexing options affect non-indexed searches. – jiggunjer – 2015-06-23T11:52:49.513

1Yes, the types are the problem, so this answer would have been better if it hadn’t ended just before mentioning the fix. – Synetech – 2015-11-17T18:17:34.727

In Windows 10 that option is in menu ViewOptionsChange folder and search options → tab Search. – Peter Mortensen – 2018-08-01T13:19:45.280

2+1 for the Indexing Options. These are VERY IMPORTANT because they define what Windows means by "searching" a file. e.g. I have an ANT build script .properties file that Windows would not search because it wasn't configured to treat it as a text file. – Richard Le Mesurier – 2012-10-31T11:30:40.443

6

The answer by Sean Sexton gave me what I was looking for (putting "content:" in the search text box). But I think the following graphical explanation might be of help to others.

The equivalent of this search in XP Search Companion (dog):

XP Search Companion

is this in Windows 7:

Windows 7 Search

Jeff Roe

Posted 2009-10-25T02:02:48.630

Reputation: 291

2Didn't work for me (with *.srt (plaintext subtitle files)). – Aaron Thoma – 2015-08-09T11:16:08.307

"content:" is ignored... just make the test search the same string with and without "content:" and verify it... – ZEE – 2015-11-11T13:46:15.047

1@JeffRoe, I cannot get Windows to search inside .sql files. Did you actually get the expected results? I can’t help but notice that you cropped the screenshot just above the search results… – Synetech – 2015-11-17T18:20:05.943

@Synetech: Yes, I definitely got the expected results. Sorry, I'm not sure what would be different in your system that would prevent it from working. – Jeff Roe – 2015-11-17T18:58:34.723

3

In Windows XP you could add further (text) file types to be searched via the registry:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.dita\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

I'm not sure whether this works with Windows 7 as well.

BennyInc

Posted 2009-10-25T02:02:48.630

Reputation: 638

1This seems to do the trick in Windows 7. Unfortunately you have to create a file association for each and every damn file extension you want to search inside, but it at least it works and doesn’t require modifying the admin-level registry. – Synetech – 2015-11-17T19:07:37.163

2I don't understand this answer, is what's posted an example of adding the filetype .dita to windows search? – Herman Toothrot – 2016-06-02T13:16:32.537

1Yes, that is for a .dita extension. – BennyInc – 2016-06-04T09:04:54.723

3

Have you tried search the internet for the correct iFilter (for instance - http://www.ifilter.org/)?

If you have the right iFilter, Windows should be able to search and index its content.

rifferte

Posted 2009-10-25T02:02:48.630

Reputation: 252

And what if I don’t use the indexer, then what? – Synetech – 2015-11-17T18:20:40.963

1do i need an "iFilter" for every file extension ? – None – 2009-10-25T03:09:38.013

Most likely yes - as each file extension assumes that the file contents would be specific for a particular extension. – rifferte – 2009-10-25T03:18:23.173

– rifferte – 2009-10-25T03:20:22.453

2

You could try using Cygwin or grep version for Windows and searching *nix commands and search using the grep utility.

From Manual:

grep options pattern input_file_names

Using the Google gnuwin32 package, there is a grep version for Windows.

chrisjlee

Posted 2009-10-25T02:02:48.630

Reputation: 3 342

1

Windows 7 SP1 ignores content: and contents: for me now, and it looks like the mechanism has changed: Now you type in what you want, and as soon as the search starts, a row at the bottom shows up with "Search again in:" Libraries, Computer, Custom, Firefox, and most importantly, File Contents. Click that and it restarts the search within files, even if the folder is unindexed.

SilverbackNet

Posted 2009-10-25T02:02:48.630

Reputation: 962

1Like the OP clearly explained, this does NOT work for certain file types.◔_◔ – Synetech – 2015-11-17T18:21:26.007

3on my machine File Contents is not given as an option – Richard Le Mesurier – 2012-10-31T11:25:55.273

Are you using Win8? There, it's changed to where you have to click on the search tab, open Advanced Options, then File Contents. – SilverbackNet – 2012-10-31T21:03:09.757

1Win 7 Home Premium 64bit SP1... strange its not there; commented to alert other confused readers (cos this issue really rattled me a lot and almost led to a BIG mistake sending passwords to a client in a file that wasn't being scanned as text) – Richard Le Mesurier – 2012-11-01T05:14:30.207