In windows 7 - I want to search for all files containing "A word or phrase in the file". The standard XP search box.

Anonymous
2009-12-06T19:24:59+00:00

In Windows 7 - I want to search/find all files containing "A word or phrase in the file".  The old standard XP search box.

I do NOT supply: file name; file type; drive letter; etc. - nothing.  

I tried searching for this - just can't find any discussion.  And of course, not having this search would be insane. It is precisely what we have a computer for. 

And no 3rd party programs are allowed.

Windows for home | Previous Windows versions | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2010-08-19T18:11:15+00:00

I've been looking into this because I know the search has been failing for me.  I think the difference in whether Windows search works or not depends on the FILE EXTENSION which contains your search text.  For example, if you look for the word "spam", it will be found if it is in a whatever.doc file, or whatever.txt file.  However, if you were to rename the file to whatever.xyz, it will no longer find the word.

Here are all the steps I think you need to follow to actually search:

  1. Make sure that Windows 7 is actually going to search files with your extension, and it appears that using this list properly is important *whether or not you are looking in an indexed location*!!

    a.  Hit the start button and type "search" in the search box.

    b.  Select "Change How Windows Searches"

    c.  Hit "Advanced"

    d.  Select the "File Types" tab.

    e.  Make sure the file extension for the files you want to search in is on the list *and* is set to "Index Properties and File Contents" (yes, pick your jaw up off the floor).  I know this appears to be for file indexing, but it does seem to make a difference on whether you find the file in non-indexed locations as well.

    f.  Say "Ok" and exit all the dialog boxes

2.  Actually perform your search on the folder in question.  Depending on some other settings you may have to type "content: spam" to find "spam" *in* the files instead of files with the word "spam" in the name.  Alternately, if you press the "Alt" key when you're exploring in the folder, you can choose "Tools / Folder Options" go to the "Search" tab and select "Always search file names and contents".

If what I have written is actually correct, then IMHO Microsoft has coughed up the ball bigtime on this one.  Personally, I now recognize that I can't use the search feature, and I'm installing Cygwin so I can use "grep" to search the contents of files.  Not cool and not amused.

Good luck to all the searchers.

~Pete

Was this answer helpful?

100+ people found this answer helpful.
0 comments No comments
Answer accepted by question author
@CmdrKeene 90,631 Reputation points Volunteer Moderator
2010-09-19T13:39:48+00:00

There is an option that seems to match what you're looking for:


If this was helpful, please vote by clicking the green triangle. If it solves the issue, click Propose as Answer. Thanks!

Was this answer helpful?

20+ people found this answer helpful.
0 comments No comments
Answer accepted by question author
Anonymous
2009-12-09T00:08:07+00:00

To find "phrase in the file" type content:"phrase in the file" in the searchbox.

Was this answer helpful?

20+ people found this answer helpful.
0 comments No comments

364 additional answers

Sort by: Newest
  1. Anonymous
    2012-06-07T01:41:59+00:00

    Just because this was annoying me to no end and neither of our previous solutions QUITE worked, I present to you the following as search.bat

    enjoy!

    @echo off

    setlocal enabledelayedexpansion

      echo for file and phrase, wildcards must be escaped. '.' is any single character rather than '?'

      echo * means repeat the previous character or class

      echo see http://www.computerhope.com/findstr.htm for full wildcard details

      echo to search in '*.bat', you would specify '.*.bat'

      echo wonderfully complicated, isn't it?

      echo.

      REM read in params if they exist

      set prm=0

      set retval1=

      call :CVRTDELIM "%*"

      set into=%retval%

      call :INPARAMS %into%

      IF %prm%==0 (

        echo Command line usage: /d="C:\mydir" /e=".*.bat" /p="phrase to search"

        echo You may not use ~ or = within any of the parameters

        set /p directory="Directory To Search: "

        set /p extension="Files Named: "

        set /p phrase="Phrase in File: "

      )

      IF "a%directory%"=="a" (

        SET directory=.

      )

      IF "z%phrase%"=="z" (

        IF "z%extension"=="z" (

          echo You must input either a filename/type or a phrase to look for in the files

          @EXIT /b 1

        )

      ) 

      set "sear=/b/s ^"%directory%^""

      SET exttxt=""

      SET phtxt=""

      IF NOT "a%extension%"=="a" (

        SET exttxt="|findstr "%extension%""

      )

      IF NOT "a%phrase%"=="a" (

        SET phtxt="|findstr /i /F:/ /C:"%phrase%""

      )

      for /f "usebackq tokens=*" %%a in ('%exttxt%') do set exttxt=%%~a

      for /f "usebackq tokens=*" %%a in ('%phtxt%') do set phtxt=%%~a

      SET seatxt="%sear%%exttxt%%phtxt%"

      for /f "usebackq tokens=*" %%a in ('%seatxt%') do set stripped=%%~a

      set strip2=%stripped:^^=%

      @echo on

      dir %strip2%

    @endlocal

    @echo Press any key to exit

    @pause

    @EXIT /b 0

    :INPARAMS

    REM  CALL :PRINTPARS %*

    :IPL1

      IF z%1==z GOTO:EOF

      for /f "usebackq tokens=1,* delims=~" %%a in ('%1') do (

        IF NOT "z%%a"=="z" (

          set pt="%%a"

          set inval="%%b"

          for /f "usebackq tokens=*" %%g in ('!inval!') do set inval=%%~g

          for /f "usebackq tokens=*" %%g in ('!inval!') do set inval=%%~g

          if !pt!=="/p" (

            set phrase=!inval!

            set prm=1

          ) else (

        if !pt!=="/e" (

              set extension=!inval!

              set prm=1

            ) else (

              if !pt!=="/d" (

                set directory=!inval!

                set prm=1

              )

            )

          )

        )

      )

    REM  echo " D:%directory% E:%extension% P:%phrase%"

      SHIFT

      GOTO :IPL1

      GOTO:EOF

    :CVRTDELIMINDIV

      FOR /F "usebackq tokens=1,* delims==" %%a in ('%*') do (

        if NOT "z%%b"=="z" (

          set retval=%%a~"%%~b"

              call :CVRTDELIMINDIV !retval!

            )

            if "z%%b"=="z" (

              set retval=%%~a

            )

      )

      GOTO:EOF

    :PRINTPARS

        echo.%~0

        echo.%~1

        echo.%~2

        echo.%~3

        echo.%~4

        echo.%~5

        echo.%~6

        echo.%~7

        echo.%~8

        echo.%~9

      echo 0%*

      GOTO:EOF

    :CVRTDELIM

      REM CALL :PRINTPARS %*

      CALL :CVRTDELIMINDIV %*

    rem  echo %retval%

      REM CALL :PRINTPARS %retval%

      GOTO:EOF

    P.S. microsoft's token parsing blows chunks

    Was this answer helpful?

    0 comments No comments