How to Delete Files, Folder and Subfolders using Command Prompt

0

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)

Advertisement

and Enter the following command

del /q “C:\Temp\*”

Replace C:\Temp\ with your desired directory

Advertisement

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

Advertisement

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.

Advertisement

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here