0

How do I search for a keyword in all the text files from a folder? I am using Vista.

0

5 Answers 5

4

%> findstr 'keyword' *.txt

1

In addition to the answers on this question,
I can also recommend Agent Ransack:

Agent Ransack is a free tool for finding files and information on your hard drive fast and efficiently. When searching the contents of files Agent Ransack displays the text found so you can quickly browse the results without having to separately open each file!

Agent Ransack provides compelling advantages over similar search tools:

  • Regular expressions that allow complex rule based searches.
  • Immediate contents results view.
  • Various wizards to walk the user through the searching process.
1

Even better: Microsoft or Google Desktop Search (Free Software by M$ and Google).

They are able to index all sort of files (even pdf, doc, xls and that like).

So you can query the index instead of time-wasting searching with the con of having/building a large index and updating it.

0

To search files by file contents you must first enable it, since by default it's only enabled in indexed locations:

  • open any folder
  • menu Tools -> Folder Options
  • select tab Search, enable Always search file names and contents (might be slow)
  • press OK

To search:

  • go to the folder where you want to search
  • in search box type 'ext:txt keyword' (without quotes)

This will search for word keyword in all file names and contents in txt files. Keyword must be a separate word. To also include cases where keyword is part of a word (either in contents or file name) use wildcards like this

ext:c *keyword*
0

The findstr may be extremely helpful, but the most powerful tool you're looking for here may be grep.

You must log in to answer this question.