# Delete contents within a folder?



## TechnoBlast

I'm trying delete folders and files within a folder usingg a batch file.

The commands I have tied delete the files, but not the folder.

For example, I have files and folders in the c:\test\exam directory. I want to delete everything that's in the EXAM folder and keep the EXAM folder intact.

I have found several commands, but the ones I found keeps deleting the EXAM folder, which I want to keep intact because of permissions purposes.

Anyone have any ideas?

Thanks.


----------



## TheOutcaste

*Del /F /Q /S c:\test\exam\*.**
This will delete all files in c:\test\exam and all files in any subfolders under c:\test\exam, but will leave the empty subfolders.

To delete all files, files in subfolders, and then delete the subfolders as well, use this:
*@For /D %%I in (C:\test\exam\*.*) DO RD /s /q %%I*

If you want to test this at a command prompt use only one % symbol

HTH

Jerry


----------



## DaveBurnett

deltree /y c:\test\exam
mkdir c:\test\exam


----------



## Dan Penny

deltree /y c:\test\exam\*.*


----------

