# Does Windows search for a word in a file work?

**URL:** <https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422>\
**Category:** Factual Questions\
**Created:** [November 9, 2011, 7:43pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422 "2011-11-09T19:43:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Charles](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@Greg\_Charles](https://boards.straightdope.com/u/Greg_Charles)\
**Post date:** [November 9, 2011, 7:43pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/1 "2011-11-09T19:43:12Z")

</div>

I’ve never got this to work right.

I use the File Explorer to go to a parent folder for my project. I hit the Search button, then explain I’m looking for "All files and folders. I put in “\*.xml” for the file name, and “encrypt” for the word or phrase. (Both without quotes.) I tell it to search, and get no results.

Dropping to a Cygwin bash window and going to the same parent folder, I type:  
find . -name \*.xml -exec grep -l encrypt {} ;

I get a listing of the four xml files that contain the word encrypt. So what am I doing wrong in Explorer?

I’m using Windows XP.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [November 9, 2011, 8:05pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/2 "2011-11-09T20:05:44Z")

</div>

I’m pretty sure all Windows Explorer search does is search filenames. I remember a search option inside MS Word a long time ago that would search inside files for text strings, but that was a long time ago.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [November 9, 2011, 8:10pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/3 "2011-11-09T20:10:09Z")

</div>

Ah, I found this: [http://support.microsoft.com/default.aspx?scid=kb;en-us;309173](http://support.microsoft.com/default.aspx?scid=kb;en-us;309173)

> [@](#):
>
> When you search for files that contain text by using the A word or phrase in the file search criterion, the search results may not contain files that contain the text that you specified. For example, .log, .dll, .js, .asp, **.xml** , .xsl, .hta, .css, .wsh, .cpp, .c, or .h files, or files with no file name extension, may not appear in the search results even if the files contain the text that you specified. This problem may occur even if you specified the file name or type in the All or part of the file name box.

(emphasis added)

Possible solutions at the link.

[This guy](http://uncletravistech.blogspot.com/2004/07/fixing-windows-xp-search-to-look.html) said method 2 worked for him.

---

<div class="post-metadata">

**Author:** ![Greg\_Charles](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@Greg\_Charles](https://boards.straightdope.com/u/Greg_Charles)\
**Post date:** [November 9, 2011, 9:08pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/4 "2011-11-09T21:08:53Z")

</div>

Neither of those methods actually worked for me. The “With Indexing Service (for faster local searches)” simply doesn’t appear to me, though I definitely have a newer service pack than the one from 2001 that they mention. Oh, well. At least I know now that this is another one of those “Windows and its wacky default settings” problems. I’ll just keep using Cygwin find. Thanks for the info!

---

<div class="post-metadata">

**Author:** ![Blakeyrat](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Blakeyrat](https://boards.straightdope.com/u/Blakeyrat)\
**Post date:** [November 9, 2011, 9:10pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/5 "2011-11-09T21:10:50Z")

</div>

> [@Greg\_Charles](#):
>
> Neither of those methods actually worked for me. The “With Indexing Service (for faster local searches)” simply doesn’t appear to me, though I definitely have a newer service pack than the one from 2001 that they mention. Oh, well. At least I know now that this is another one of those “Windows and its wacky default settings” problems. I’ll just keep using Cygwin find. Thanks for the info!

Since XP is going out of support soon anyway, you might consider upgrading. Windows 7’s search indexer is much, much, much better.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [November 9, 2011, 9:11pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/6 "2011-11-09T21:11:38Z")

</div>

Do you have indexing turned on? If not, that may explain the option not appearing.

---

<div class="post-metadata">

**Author:** ![filmore](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@filmore](https://boards.straightdope.com/u/filmore)\
**Post date:** [November 9, 2011, 9:19pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/7 "2011-11-09T21:19:22Z")

</div>

> [@Greg\_Charles](#):
>
> Dropping to a Cygwin bash window and going to the same parent folder, I type:  
> find . -name \*.xml -exec grep -l encrypt {} ;

I agree about the crappy Windows text search. I use cygwin as well. One improvement to your search is to use xargs like this:

find . -name \*.xml | xargs grep -l encrypt

That way grep will only be run once for all the files instead of one time for each file.

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [November 9, 2011, 10:14pm UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/8 "2011-11-09T22:14:47Z")

</div>

I’ve never found Windows XP very reliable for searching inside files - not only does it skip right over some file types, it’s also pretty flaky about partial word searches (or something like that). If you search for ‘banana’ and it appears in the file as bigbendybanana, it might not consider that a match.

I installed PRGrep on my machine and I just use that instead - it’s better anyway, for all kinds of reasons.

---

<div class="post-metadata">

**Author:** ![Greg\_Charles](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@Greg\_Charles](https://boards.straightdope.com/u/Greg_Charles)\
**Post date:** [November 10, 2011, 1:16am UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/9 "2011-11-10T01:16:44Z")

</div>

> [@filmore](#):
>
> I agree about the crappy Windows text search. I use cygwin as well. One improvement to your search is to use xargs like this:
> 
> find . -name \*.xml | xargs grep -l encrypt
> 
> That way grep will only be run once for all the files instead of one time for each file.

That’s incredibly helpful. Thanks!  
I do agree about upgrading XP, but it’s a work computer and so not my choice. There’s apparently some issues with the way Windows 7 interacts with our disk encryption. If it were my choice, I’d replace everything with Macs!

---

<div class="post-metadata">

**Author:** ![Greg\_Charles](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@Greg\_Charles](https://boards.straightdope.com/u/Greg_Charles)\
**Post date:** [November 10, 2011, 1:19am UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/10 "2011-11-10T01:19:00Z")

</div>

> [@KneadToKnow](#):
>
> Do you have indexing turned on? If not, that may explain the option not appearing.

According to my C: drive properties, I do in fact have indexing turned on.

---

<div class="post-metadata">

**Author:** ![AnalogSignal](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/analogsignal/32/1085_2.png) [@AnalogSignal](https://boards.straightdope.com/u/AnalogSignal)\
**Post date:** [November 10, 2011, 1:50am UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/11 "2011-11-10T01:50:01Z")

</div>

I have [Windows Search 4.0 for Windows XP](http://www.microsoft.com/download/en/details.aspx?id=23) installed on my Windows XP PC.

It does successfully search Word docs, Excel docs, PDFs, Outlook email messages. I use it constantly for Outlook searches. However, it takes time to configure it to index properly.

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [November 11, 2011, 3:19am UTC](https://boards.straightdope.com/t/does-windows-search-for-a-word-in-a-file-work/602422/12 "2011-11-11T03:19:57Z")

</div>

The Windows [findstr command](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/findstr.mspx) is much more reliable and versatile than XP’s GUI search, and doesn’t require installing Cygwin.
