How to Delete Files, Folder and Subfolders using Command Prompt


Do you want to delete files and subfolders in a specific folder using CMD. Here i am going to tell you how to delete files and subfolders using command prompt.

Delete files using CMD

Open CMD ( Don’t run as Admin)

and Enter the following command

del /q “C:\Temp\*”

Replace C:\Temp\ with your desired directory

Note:- Above command will only delete files in that folder it will not delete sub folders.

Delete files and subfolders within a folder using CMD

This method is little bit different, here we are not going to enter command in cmd instead we will be creating a .bat file.

Open Notepad and type the following code

del /q “C:\Temp\*”
FOR /D %%p IN (“C:\Temp\*.*”) DO rmdir “%%p” /s /q

Here in both lines replace C:\Temp\ with the directory you want to delete.

Save file as delete.bat

Now Double click to run that bat file. This bat file will delete all files and subfolders within a folder.

If you still have any doubt ask in comment section below.


Please enter your comment!
Please enter your name here