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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ca060728
Posts: 1
Joined: 28 Nov 2009 16:33

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

#1 Post by ca060728 » 28 Nov 2009 16:44

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

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 02 Dec 2009 13:47

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.

Post Reply