View Full Version : I want to erase lots of files with .bat
jan tanjo
03-24-2006, 03:52 PM
Hi guys
I have a list of files (over 400) that I want to delete from a directory with a lot of other files (over 4000) that I want to keep, how would I write a batch file to accomplish this? Would it be easy to make this unattended?
I've spent about 30 minutes Googling this but I don't know how to word the search to get anything useful, (to me)
Paul Komski
03-24-2006, 08:07 PM
If there is a common denominator (such as file extension or file size or ...) then you could just search that directory (RClick and Search) for those parameters and then simply select all and delete - without using a batch file at all.
Otherwise use wildcards to select the files such as:
del c:\test\*.txt
to delete all txt files in the test directory
or
del c:\test\help????.???
to delete all 8dot3 files called helpXXXX.XXX
eg helpfile.txt and helpboss.mdb
or
del c:\test\a??.???
to delete all 8dot3 files called aXX.XXX
eg ape.txt and all.xls and ass.doc
Try searching google for DOS delete functions and then test batch file on a test directory. There is probably a switch that can prevent you being given a warning prior to deletion. Etc, etc.
tommy
03-25-2006, 02:39 AM
Paul's reply is right on. The switch he refers to is /p. That is, use the DEL statements as suggested followed by a space plus /p.
His first example then would be:
del c:\test\*.txt /p
That will ask for a confirmation (Y/N) before deleting each file.
An alternative would be to use MY COMPUTER, set VIEW to DETAILS and then click on the desired folder.. That will give you a list of all the files in the wanted folder. Just highlight (single click on the icon) as many of the files you want to delete and then click on the delete icon. Might be faster because you would not have to debug a batch file and the deleted files would be placed in the recycle bin and would be recoverable in case you goofed. With a batch file, once they are deleted, they are gone for good.
tommy
03-25-2006, 04:14 AM
OOPS, almost forgot. In prior post ---
Just highlight (single click on the icon) as many of the files you want to delete
should read---
Just highlight (HOLD DOWN THE CONTROL KEY AND single click on the icon) as many of the files you want to delete
Holding down the CONTROL key while selecting is what allows you to make multiple selections and then do one delete.
vBulletin v3.6.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.