Page 1 of 1

How to get a value from txt filt and restore it invaliable

Posted: 28 Nov 2009 16:44
by ca060728
Hi every one,

I am new here and I have a problem. I want to write batch file that search txt files. If a file has a fixed string, such as "I love", the file would be erased.

How can I do it?

Thanks in advance for any help!
:D

Posted: 02 Dec 2009 13:47
by avery_larry
set "searchdir=c:\dir to search"
set "stringtofind=whatever you want"

cd /d "%searchdir%"
for %%a in (*.txt) do find /i "%stringtofind%" && echo del "%%~a"


TEST THOROUGHLY FIRST! Remove the "echo" to actually del files.