How to delete a folder and all contents using a bat file in windows?
388,576
Solution 1
@RD /S /Q "D:\PHP_Projects\testproject\Release\testfolder"
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
del /s /q c:\where ever the file is\*
rmdir /s /q c:\where ever the file is\
mkdir c:\where ever the file is\
Related videos on Youtube
Author by
learner
Updated on July 19, 2022Comments
-
learner almost 2 years
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?
-
Hakikat41 over 3 yearsCan you please explain, why the @ flag befor RD ist needed and used? In the explanation there is only with rd.
-
Waihon Yew over 3 years@Hakikat41 it's the symbol for reducing verbosity in batch files. It doesn't affect the operation of the command itself, and doesn't do anything outside of batch files. Looking at the question, I imagine I put it there because the question itself has the
DEL
command with it included. -
yu yang Jian over 2 yearsto delete all subfolders in a folder, use
*
infor
:for /d %G in ("D:\testfolder\*") do rd /s /q "%~G"