<http://www.netikka.net/tsneti/info/tscmd130.htm>
Copyright © 2003-2010 by Prof. Timo Salmi  
Last modified Mon 17-May-2010 21:38:48

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



130} How do I find and delete files which contain a specific text?

I have a folder which contains about 250000 files. File explorer chokes or is slow when I try to search for files which contain a certain a certain phrase. I would like to delete these files without using a gui program. What's the dos syntax to do this in a command prompt?

As by the script solution below. Incidentally, note explicitly not using the errorlevel, but  &&  instead.
  @echo off & setlocal enableextensions
  for %%f in ("C:\wherever\*.*") do (
    find /i "whatever" "%%f">nul&&ECHO del "%%f")
  endlocal & goto :EOF

Warning! The "ECHO" is included for some safety. Careful, as always! Use scripts with del or other powerful commands at your own risk! A del from command line or from a script is irreversible.

References/Comments:
  hh ntcmds.chm::/ntcmds_shelloverview.htm