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 delete files, folders and subfolders in 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
Related: How to delete Files older than X days in Windows.
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.