Computing.Net > Forums > Programming > bat to delete .txt based on content

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

bat to delete .txt based on content

Reply to Message Icon

Name: ctt2
Date: April 30, 2007 at 21:09:41 Pacific
OS: windows xp
CPU/Ram: p4 3.2ghz
Product: intel
Comment:

I need a windows batch file that will recurse sub directories and the current directory looking for .txt files containing the text "Redirecting to" and delete those files.

I have over 100,000 data files in subdirectories and many of them have full articles, many of them also just have 1 line that say "Redirecting to 'somerandomthing'"
I need to eliminate these files automatically.

Thank you,
CTT



Sponsored Link
Ads by Google

Response Number 1
Name: ctt2
Date: April 30, 2007 at 21:27:59 Pacific
Reply:

Nevermind I figured it out, here it is for anyone else that needs the same operation.

FOR /F "delims=" %F IN ('findstr /m /c:"Redirecting to" *.txt') DO DEL "%F" /Q


0

Response Number 2
Name: ctt2
Date: April 30, 2007 at 21:31:39 Pacific
Reply:

oops, there should be two % infront of the F's so here is the correct version...

FOR /F "delims=" %%F IN ('findstr /m /c:"Redirecting to" *.txt') DO DEL "%%F" /Q


0

Response Number 3
Name: ctt2
Date: April 30, 2007 at 21:42:50 Pacific
Reply:

OK one thing that this doesn't do is recurse subdirectories and I can't figure out how to make it do that. Anyone know?


0

Response Number 4
Name: ctt2
Date: April 30, 2007 at 22:01:00 Pacific
Reply:

Ok adding /s in the findstr command allows it to recurse subdirectories, now it works perfect..

FOR /F "delims=" %%F IN ('findstr /s /m /c:"Redirecting to" *.txt') DO DEL "%%F" /Q


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: bat to delete .txt based on content

Txt renamer from content? www.computing.net/answers/programming/txt-renamer-from-content/18393.html

Moving Messages based on content www.computing.net/answers/programming/moving-messages-based-on-content/15376.html

Move a XML file based on content www.computing.net/answers/programming/move-a-xml-file-based-on-content/18945.html