How to delete files and folders using Command Prompt in Windows 10

At times, all our attempts to delete files or folders via File Explorer yield no results. Many reasons can be attributed to the failure, which can lock down the files/folders and prevent their deletion. In such cases, you can use the Command Prompt to delete files, folders, and subfolders.

Delete files & folders using Command Prompt

Delete files & folders using Command Prompt

First things first, using the Command Prompt incorrectly may render your system inoperable, and at the time you will not be able to recover deleted files. So proceed carefully and exercise extreme caution.

There are multiple ways via which you can delete a file or a folder on your Windows system. It is possible that you’ll run into problems if the file is locked. This is where the Command line prompt finds its real utility.

To delete files using Command Prompt, make sure to open it with admin privileges.

1] Delete the desired file

When the CMD window opens, navigate to the folder where the file is available. You will have to use the “cd” or change directory command. Then, use the following command with options in the prompt:

DEL /F /A <file path with extension>


  • /F stands for force delete
  • /A selects only the files with ready for archiving attribute

2] Delete the desired folder

Navigate to the folder containing the folder you wish to delete by using the ‘cd’ command. Type the following command in the Command Prompt:

RD /S <folder path>


  • RD removes the folder from the directory.
  • /S Removes all subfolders and files

If you use the /Q parameter also, then you will not be asked for the Y/N confirmation.

If the folder or file is locked, you can follow these instructions to delete locked or undeletable files & folders.

Try this and let us know in the comments section below if the method works for you. You can use the same commands using PowerShell.

Posted by on , in Category Windows with Tags
Anand Khanse is the Admin of, a 10-year Microsoft MVP Awardee in Windows (2006-16) & a Windows Insider MVP. Please read the entire post & the comments first, create a System Restore Point before making any changes to your system & be careful about any 3rd-party offers while installing freeware.

Leave a Reply

Your email address will not be published. Required fields are marked *

7 + 9 =