Computing.Net > Forums > Programming > Delete files containing known text

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.

Delete files containing known text

Reply to Message Icon

Name: keridbey
Date: June 5, 2008 at 04:38:31 Pacific
OS: WinXP Pro
CPU/Ram: 1.83 Ghz / 1 Gb
Product: Dell
Comment:

I'm trying to find a way via either batch file or VBS to check the contents of a large number of .TXT files in a particular directory for the words "delivery failure" (case insensitive) and delete only the files that contain that phrase. I have thousands of files to go through, so a script of some sort is going to be a must. Any thoughts? Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 5, 2008 at 05:47:50 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b *.txt') do (
find /i "delivery failure" < %%a > nul
if not errorlevel 1 echo del %%a
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: keridbey
Date: June 5, 2008 at 07:25:38 Pacific
Reply:

Outstanding! Thank you very much; it works perfectly!!!


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: Delete files containing known text

delete known text from txt file www.computing.net/answers/programming/delete-known-text-from-txt-file/15684.html

Delete Files Older Then x-Days www.computing.net/answers/programming/delete-files-older-then-xdays/15229.html

echo text to specific line in file www.computing.net/answers/programming/echo-text-to-specific-line-in-file/11965.html