How to delete a folder and all contents using a bat file in windows?

WindowsBatch FileCommandDelete File

Windows Problem Overview


I want to delete a folder with all files and subfolders using a bat file.

I have tried the following, but it is not working:

@DEL D:\PHP_Projects\testproject\Release\testfolder*.*

Can anybody help?

Windows Solutions


Solution 1 - Windows

@RD /S /Q "D:\PHP_Projects\testproject\Release\testfolder"

Explanation:

> Removes (deletes) a directory. > > RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path > > /S Removes all directories and files in the specified directory > in addition to the directory itself. Used to remove a directory > tree. > > /Q Quiet mode, do not ask if ok to remove a directory tree with /S

Solution 2 - Windows

  1. del /s /q c:\where ever the file is\*
  2. rmdir /s /q c:\where ever the file is\
  3. mkdir c:\where ever the file is\

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlearnerView Question on Stackoverflow
Solution 1 - WindowsJonView Answer on Stackoverflow
Solution 2 - Windowsuser3319853View Answer on Stackoverflow