How to search inside files on Windows 7?

830,175

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 5

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

Share:
830,175

Related videos on Youtube

Breakthrough
Author by

Breakthrough

Updated on September 17, 2022

Comments

  • Breakthrough
    Breakthrough over 1 year

    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?

    • Admin
      Admin over 8 years
      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.
    • Admin
      Admin about 6 years
      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.
  • rifferte
    rifferte over 14 years
    Most likely yes - as each file extension assumes that the file contents would be specific for a particular extension.
  • rifferte
    rifferte over 14 years
    Also - please review these two links - they have lots of content that should help you out: microsoft.com/windows/products/winfamily/desktopsearch/… gallery.live.com/default.aspx?pl=6
  • Admin
    Admin over 14 years
    Or maybe by using the the FIND command instead.
  • Will J
    Will J over 14 years
    AstroGrep is lean & mean. 80k, lightning fast, & searches network locations. Thanks for the heads up on this tool.
  • Synetech
    Synetech over 13 years
    @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.
  • David Yates
    David Yates about 13 years
    @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)
  • Sobhana Kr
    Sobhana Kr almost 13 years
    @Synetechinc. You can say: find "word" *
  • Synetech
    Synetech almost 13 years
    Hmm, 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. :-|)
  • Kelly Pedrick
    Kelly Pedrick almost 13 years
    Doesn't seem to work
  • Avram
    Avram almost 13 years
    @ThomasMcLeod working to me, maybe you need the "searching in nonindexed files"
  • Steve
    Steve almost 13 years
    @nikhil: Unfortunately you don't mention how to get to Indexing Options, nor does the page you link to.
  • Admin
    Admin almost 13 years
    @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.
  • Pierre
    Pierre over 12 years
    For Windows 7 it looks like it's content: not contents:
  • mjustin
    mjustin over 12 years
    I found that it is also localized, in German for example inhalt:
  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 12 years
    @Nikhil, is there a way to search within files in unindexed locations as well?
  • HaydnWVN
    HaydnWVN over 12 years
    'contents:$$$' where $$$ is the content i'm looking for works for me in Windows 7
  • HaydnWVN
    HaydnWVN over 12 years
    -1 as it doesn't search in non-indexed locations, even when the option is selected. @Shimmy Sean's answer below does.
  • Rodniko
    Rodniko about 12 years
    Wow!! this one is good!
  • SilverbackNet
    SilverbackNet about 12 years
    It 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.
  • Richard Le Mesurier
    Richard Le Mesurier over 11 years
    on my machine File Contents is not given as an option
  • Richard Le Mesurier
    Richard Le Mesurier over 11 years
    +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.
  • Admin
    Admin over 11 years
    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.
  • SilverbackNet
    SilverbackNet over 11 years
    Are you using Win8? There, it's changed to where you have to click on the search tab, open Advanced Options, then File Contents.
  • Richard Le Mesurier
    Richard Le Mesurier over 11 years
    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)
  • ingredient_15939
    ingredient_15939 about 11 years
    Also a plug here for Agent Ransack. Shell integrated, small and fast, supports regex as well.
  • Admin
    Admin about 11 years
    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.
  • kevinmicke
    kevinmicke about 10 years
    grepWin is a similarly lightweight grep tool for Windows that has different options from AstroGrep that are useful in some situations.
  • Jason H.
    Jason H. over 9 years
    The "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.]
  • kcdwayne
    kcdwayne about 9 years
    It seems to work for html, js, css, xml, sql, but unfortunately not php.
  • GTodorov
    GTodorov about 9 years
    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!
  • jiggunjer
    jiggunjer almost 9 years
    @HaydnWVN it should check non-indexed locations. Seans answer doesn't work for some people either...
  • jiggunjer
    jiggunjer almost 9 years
    Odd that indexing options affect non-indexed searches.
  • Aaron Thoma
    Aaron Thoma almost 9 years
    Didn't work for me (with *.srt (plaintext subtitle files)).
  • ZEE
    ZEE over 8 years
    +1 for AstroGREP and +1 for AgentRansack... +1 also for Cygwin grep command line tool...
  • ZEE
    ZEE over 8 years
    "content:" is ignored... just make the test search the same string with and without "content:" and verify it...
  • Synetech
    Synetech over 8 years
    The 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.
  • Admin
    Admin over 8 years
    Not using the indexer, so this does not fix the problem.
  • Synetech
    Synetech over 8 years
    Yes, the types are the problem, so this answer would have been better if it hadn’t ended just before mentioning the fix.
  • Synetech
    Synetech over 8 years
    @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
    Synetech over 8 years
    And what if I don’t use the indexer, then what?
  • Synetech
    Synetech over 8 years
    Like the OP clearly explained, this does NOT work for certain file types.◔_◔
  • Synetech
    Synetech over 8 years
    I don’t use the indexer, so this does NOT fix anything.
  • Jeff Roe
    Jeff Roe over 8 years
    @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.
  • Synetech
    Synetech over 8 years
    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.
  • John M
    John M about 8 years
    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.
  • Cyberherbalist
    Cyberherbalist almost 8 years
    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!
  • Herman Toothrot
    Herman Toothrot almost 8 years
    I don't understand this answer, is what's posted an example of adding the filetype .dita to windows search?
  • BennyInc
    BennyInc almost 8 years
    Yes, that is for a .dita extension.
  • mafu
    mafu over 7 years
    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
    mafu over 7 years
    @Synetech Why not? It's very easy to use, e.g. findstr "todo" *.txt.
  • drizin
    drizin about 7 years
    Using Powershell (I like because I can use full regex): Get-ChildItem -recurse *.config | Select-String -pattern "mystring" | group path | select name
  • Ron Harlev
    Ron Harlev about 7 years
    Created a short video to demo how to apply the solution in this answer bit.ly/2p15Ipp
  • omatai
    omatai about 6 years
    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.
  • Peter Mortensen
    Peter Mortensen almost 6 years
    In Windows 10 that option is in menu ViewOptionsChange folder and search options → tab Search.
  • MicrosoftShouldBeKickedInNuts
    MicrosoftShouldBeKickedInNuts over 5 years
    /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.
  • Henke
    Henke over 3 years
    @Peter Mortensen, or equivalently in File → Change folder and search options → Search. :-)