I needed to search through a few hundred files and directories to look for all the HTML documents that did not contain the string “jQuery.js“.
I found that the DOS command find with the parameter /c could be used to search for a string and return a “count of lines”. Adding the second parameter /i I could the search and ignore the case of the string in the search.
Borrowing from various sources I created this line of code:
find /c /i "jquery.js" C:\SITES\xyz\wwwroot\*.htm* | find ": 0";
This did provide me with a list of files that did not contain the strings jQuery.js. But, only ran in the C:\SITES\xyz\wwwroot\ and did not reference and of the sub-directories.
Next I needed a way to loop through a folder and it’s sub-directories. I found a line of code that does a for loop reading all of the files and folders an echos their name to the screen via the variable %v.
for /r %v in (*.cf*) do echo %v
After looking at the two lines of code for awhile I figured out a way to combine the line together and save the output to a file.
(for /r %v in (*.cf*) do (find /c /i "jquery.js" "%v" | find ": 0")) > c:\temp\dump.txt
The line of code does need to be run from the folder you wish to search.