FFIND ERRORLEVEL

Feb 11, 2011
10
0
#1
TCC 11.00.52

I'm using FFIND to search text files for a string. I need to know if the string was found in any of the files - it doesn't matter which specific file contained the string.

I expected that FFIND would set ERRORLEVEL (or _?) to indicate the presence or abserce of a match, but it doesn't seem to do so.

Am I missing something? Is there another command which I can use to accomplish this?
 

rconn

Administrator
Staff member
May 14, 2008
10,506
94
#2
I'm using FFIND to search text files for a string. I need to know if the string was found in any of the files - it doesn't matter which specific file contained the string.
FFIND only sets the errorlevel if there was an error -- and not finding a match is not considered an error.

If you just want to check the results to see if anything matched, you can use the FFIND /U option. If you want to test it in a batch file, you can use @EXECSTR to return the FFIND result and parse that.
 
Feb 11, 2011
10
0
#3
FFIND only sets the errorlevel if there was an error -- and not finding a match is not considered an error.

If you just want to check the results to see if anything matched, you can use the FFIND /U option. If you want to test it in a batch file, you can use @EXECSTR to return the FFIND result and parse that.
Thanks for the quick answer.