Here's a sample batch file that'll do the trick.
@echo off
setlocal
pushd D:\myfiles
rem case-insensitive search for the string "SOME TEXT" in all html files
rem in the current directory, piping the output to the results.txt file
rem in teh same directory
findstr /ip /c:"SOME TEXT" *.html > results.txt
popd
endlocal
Update: Some caveats to using findstr command.
If your string contains angle brackets, you have to escape them using the CMD escape character - ^. So, if you want to search for <TITLE>
, you have to specify it as /c:"^<TITLE^>"
.
If you want only file names, change /ip to /im. Also, you can add /s to search subfolders. In general, you can play with the different findstr options as listed in findstr /?.
Findstr will find the text only in UTF-8 encoded files. If the HTML files are UTF-16 encoded (ie, each character takes two bytes), findstr will not find the text.
I would also suggest running the command without the piping to the results.txt first to get the right findstr options and make sure it outputs what you need.