Search DOS files for text-list file

March 4, 2009 at 14:16:21
Specs: Windows Server 2003 - DOS
I need to search a directory of 75000 text files for any files containing a particular string. How can I search the files for the string and output a list of those files into a text file?

I am currently doing this:
find /C "SEARCHSTRING" *.txt > c:\Wanted.txt

however the output file is filled with non-hits as well as hits.
-------File1.txt: 0
-------File2.txt: 2
-------File3.txt: 0

in this case I only want to trap File2.txt in my output log.

See More: Search DOS files for text-list file

Report •

March 4, 2009 at 14:35:19

find /C "SEARCHSTRING" *.txt | find /V " 0" > C:\Wanted.txt

Report •

March 5, 2009 at 12:20:47
Excellent! It created blank lines in the Wanted.txt, but i pasted that in excel and sorted! Blanks drop to the bottom and good stuff to the top.

So for learning purposes the first "find /c" located any instance of the search string in the selected text file and outputted a count of the instance starting at zero.
The Pipe sent that output to the next "find /v" which omits any " 0" or count of zero.
That output is then written to the c:\Wanted.txt file.

Many Thanks!!!!

Report •

March 6, 2009 at 02:38:15
Your spelling of the statemnt is absolutely exact; by more complex scripting you can get an output that perfecly fits your needs.

NT (not DOS) batch scripting is a powerful tool to manipulate text streams.

Report •

Related Solutions

Ask Question