C:\_G\WWW\~ELISANET\INFO\tscmd130.html
<http://www.elisanet.fi/tsalmi/info/tscmd130.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Fri 30-Nov-2018 11:52:32

 
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 [You can't use this unless you have the ntcmds.chm file]

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd130.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd130
http://www.elisanet.fi/tsalmi/info/tscmd130.html
file:///c:/_g/www/~elisanet/info/tscmd130.html