Help: How to delete all files under drive D that contain the keyword "sex"? For example, there are many files under my drive D. I want to delete files whose contents contain any one of the keywords "sex", "name", "year".
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Originally posted by NaturalJ0 at 2006-9-24 04:12:
You can just use the search function in Windows, there's no need to take the trouble to write a batch script.
for /f "skip=1 delims=" %i in ('findstr /m /s /d:d:\ "sex name year" *.txt') do @echo d:\%i
@echo off
for /f "tokens=*" %%i in ('dir /a-d /b /s d:\*.txt') do (
findstr /i "sex name year" "%%i">nul && del /a /f "%%i"
)
Originally posted by he200377 at 2006-9-24 07:31:
All files containing the keyword "sex"
It's not only txt? Brother namejm
@echo off
set "strFiles=*.txt *.bat"
for /f "skip=1 delims=" %%i in ('findstr /m /s /d:d:\ "sex name year" %strFiles%') do echo d:\%%i
pause Originally posted by namejm at 2006-9-24 07:41:
I didn't understand what you meant. Do you mean that all files containing "sex" are not just referring to txt, or something else?