Search on a wildcard
Posted on 2003-11-07
I have a script which I wish to search a directory that contains a number of log files which are created by a build script which will contain values such as:
ERROR = 0
another log could contain
ERROR = 1
and another log file could contain
ERROR = 3
I have asked the quested before but with no result. I have the following script which was created by expert _nn_
In this script I search for a patern equal to ERROR = 1 which works fine, but I need to able to cover other values that "ERROR =" can contain for example 2 or 3 or 4 or 5.....or 100 etc, depending on the number of errors that my build script emits. If "ERROR = 0" then as the script covers this is to be ignored. All suggestions welcome:
:: global parameters, please adapt as needed
set PATTERN=ERROR = 1
for /f "delims=" %%a in ('dir /b *.* ^|findstr /v "1."') do call :increment "%%a"
echo Found %COUNT% occurences. Sending message...
if %COUNT% GEQ 1 (
net send pc-000024 test-BAD
) else (
net send pc-000024 test-GOOD
echo Message sent.
:: filenames without path won't have a ':'
for /f "tokens=1-2 delims=:" %%a in ('find /C "%PATTERN%" %1') do set /A COUNT=%COUNT%+%%b