252

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?

  • 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 Nov 17 '15 at 19:14
  • 1
    MS 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 Mar 20 '18 at 3:42

13 Answers 13

129

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.

  • 19
    Or maybe by using the the FIND command instead. – user8228 Oct 25 '09 at 12:10
  • 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 Mar 22 '11 at 13:08
  • 8
    @Synetechinc. You can say: find "word" * – Oscar Mederos May 17 '11 at 7:12
  • 5
    @nikhil: Unfortunately you don't mention how to get to Indexing Options, nor does the page you link to. – Steve Jul 12 '11 at 10:49
  • 8
    -1 as it doesn't search in non-indexed locations, even when the option is selected. @Shimmy Sean's answer below does. – HaydnWVN Jan 19 '12 at 13:30
113

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

  • 12
    AstroGrep is lean & mean. 80k, lightning fast, & searches network locations. Thanks for the heads up on this tool. – Sean O Nov 30 '09 at 16:39
  • 1
    Wow!! this one is good! – Rodniko Apr 22 '12 at 15:19
  • 4
    Also a plug here for Agent Ransack. Shell integrated, small and fast, supports regex as well. – ingredient_15939 Mar 8 '13 at 5:23
  • 1
    Awesome 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 Apr 11 '15 at 0:46
  • 1
    +1 for AstroGREP and +1 for AgentRansack... +1 also for Cygwin grep command line tool... – ZEE Nov 11 '15 at 13:42
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.

  • 19
    Doesn't seem to work – ThomasMcLeod May 31 '11 at 4:35
  • 17
    I found that it is also localized, in German for example inhalt: – mjustin Oct 13 '11 at 8:36
  • 3
    'contents:$$$' where $$$ is the content i'm looking for works for me in Windows 7 – HaydnWVN Jan 19 '12 at 13:29
  • 4
    Doesn'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 Oct 26 '12 at 13:52
  • 3
    It seems to work for html, js, css, xml, sql, but unfortunately not php. – kcdwayne Feb 25 '15 at 14:26
54

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.
  • @Synetech Why not? It's very easy to use, e.g. findstr "todo" *.txt. – mafu Sep 28 '16 at 11:17
  • /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 Oct 5 '18 at 8:51
16

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

14

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

  • 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 Mar 11 '16 at 4:31
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.

  • 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 Oct 31 '12 at 11:32
  • 1
    This 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 May 1 '13 at 13:20
  • Not using the indexer, so this does not fix the problem. – Synetech Nov 17 '15 at 18:16
7

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

  • 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 Oct 31 '12 at 11:30
  • Odd that indexing options affect non-indexed searches. – jiggunjer Jun 23 '15 at 11:52
  • Yes, the types are the problem, so this answer would have been better if it hadn’t ended just before mentioning the fix. – Synetech Nov 17 '15 at 18:17
  • In Windows 10 that option is in menu ViewOptionsChange folder and search options → tab Search. – Peter Mortensen Aug 1 '18 at 13:19
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

  • 2
    Didn't work for me (with *.srt (plaintext subtitle files)). – Aaron Thoma Aug 9 '15 at 11:16
  • "content:" is ignored... just make the test search the same string with and without "content:" and verify it... – ZEE Nov 11 '15 at 13:46
  • 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 Nov 17 '15 at 18:20
  • @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 Nov 17 '15 at 18:58
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.

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.

  • 1
    This 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 Nov 17 '15 at 19:07
  • 2
    I don't understand this answer, is what's posted an example of adding the filetype .dita to windows search? – Herman Toothrot Jun 2 '16 at 13:16
  • 1
    Yes, that is for a .dita extension. – BennyInc Jun 4 '16 at 9:04
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.

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.

  • 3
    on my machine File Contents is not given as an option – Richard Le Mesurier Oct 31 '12 at 11:25
  • 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 Oct 31 '12 at 21:03
  • 1
    Win 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 Nov 1 '12 at 5:14
  • 1
    Like the OP clearly explained, this does NOT work for certain file types.◔_◔ – Synetech Nov 17 '15 at 18:21

protected by Troggy Dec 17 '10 at 13:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?