It's been awhile since I've done anything with batch files but I think that the following works:
find /c "string" file | find /c ": 0"
if %errorlevel% equ 1 goto notfound
echo found
goto done
:notfound
echo not foundnotfound
goto done
:done
This is really a proof of concept; clean up as it suits your needs.
Explanation:
find /c "string" file
prints out a count of the number of times string appeared in file. It's output looks like this:
---------- FILE: #
where #The key is the number of times string appeared inthat filefind. Then I pipe this to returns an finderrorlevel again looking forof : 01 to indicate thatif string appearedis not in file zero times. find will return an errorlevel of 1 to indicate success (i.e., that the count was zero). In this case weWe branch to notfound. Otherwise in this case otherwise we handle the found case.