Incidentally, this task arose from my own need to check through a
number of html files which I had to edit. I wanted to see if I
missed making one of the intended adjustments.
@echo off & setlocal enableextensions enabledelayedexpansion
echo +---------------------------------------------------+
echo ^| NOFIND.CMD Find files not containing a string ^|
echo ^| By Prof. Timo Salmi, Last modified Sun 6-Nov-2005 ^|
echo +---------------------------------------------------+
echo.
::
:: Set the appropriate variables
set string_=%~1
set source_=%~2
set ignorecase_=%~3
set help_=
::
:: Syntax help, if necessary
if not defined source_ set help_=true
if defined ignorecase_ (
if /i not "%~3"=="/i" set help_=true
)
if defined help_ (
echo Usage: %~0 "string" "[[drive:][path]filename]" [/i]
echo Wildcards allowed
echo Search also subfolders implicitly assumed
goto :EOF)
::
:: Do the nofind recursively
for /f %%f in ('dir /b /s "%source_%"') do (
set file_=%%~dpnxf
find %ignorecase_% "%string_%" "!file_!">nul
if !errorlevel! NEQ 0 echo !file_!
)
endlocal & goto :EOF
An example of usage: