bat to delete .txt based on content
|
Original Message
|
Name: ctt2
Date: April 30, 2007 at 21:09:41 Pacific
Subject: bat to delete .txt based on contentOS: windows xpCPU/Ram: p4 3.2ghzModel/Manufacturer: 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
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: ctt2
Date: April 30, 2007 at 21:27:59 Pacific
Subject: bat to delete .txt based on content |
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: ctt2
Date: April 30, 2007 at 21:31:39 Pacific
Subject: bat to delete .txt based on content |
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: ctt2
Date: April 30, 2007 at 21:42:50 Pacific
Subject: bat to delete .txt based on content |
Reply: (edit)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?
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: ctt2
Date: April 30, 2007 at 22:01:00 Pacific
Subject: bat to delete .txt based on content |
Reply: (edit)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
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: