Delete all files and folders in a directory

Viewed 479829

I want to have a batch file that will delete all the folders and files in my cache folder for my wireless toolkit.

Currently I have the following:

cd "C:\Users\tbrollo\j2mewtk\2.5.2\appdb\RMS"
del *.db

This will delete all .db files in my RMS directory, however I want to delete every single thing from this directory. How can I do this?

17 Answers

Easy simple answer :

C:
del /S /Q C:\folderName\oderFolderName\*

C: Important in case you have to switch from D: to C: or C: to D: (or anything else)

/S Recursive, all subfolders are deleted along

/Q If you don't activate quiet mode, prompt will ask you to type y for every subfolders... you don't want that

Be carful, it's drastic.

I would like to suggest using simple tool like cleardir. So, in batch file you can write:

cleardir path/to/dir

And you'll get empty directory dir. A bit slow, but still resolves the "problem".

I'm an author of the tool =)

The easiest way is:

  1. Create *.txt file
  2. Write: rmdir /q /s . dir
  3. Save file as *.bat in folder which you want to clear (you can call the file NUKE.bat)
  4. Turn it on

WARNING!

THIS DELETES EVERYTHING IN THE FOLDER WHERE IT IS WITHOUT ASKING FOR CONFIRMATION!!!

SO CHOOSE WISELY PLACE FOR SAVING IT.

Related