To delete a folder or file permanently from your Windows 10 OS, you can use the command line.
There are built-in Windows commands to delete specific folders and files from your system.
In the following guide, I will use Command Prompt or cmd to delete folders, subfolders, and files from your PC. So, keep reading.
How To Delete A Folder And Subfolders In Command Prompt?
Follow the steps and learn how to make cmd delete folders and files easily from the directories.
How To Delete Folders Using Command Prompt?
For deleting folders using Command Prompt, run the rmdir delete folder command line. This is Windows built-in command to delete folders.
This command deletes the folders along with all the subfolders in it.
But before using this command line to delete a folder, remember that rmdir will not move the folders to the Recycle Bin.
It will delete the folders permanently. So, be cautious while deleting the folders using Command Prompt.
Here is how to delete the folders in Command Prompt:
- Enter cmd in the Windows search bar and right-click on Command Prompt. Select the Run as administrator option.
- In the elevated Command Prompt window enter the following command and then press the Enter key:
rmdir “your folder path”
Look at the image. Here I have entered my folder path after rmdir.
This will delete the folder that does not contain any subfolder or file.
Always make sure to enter the entire folder path. It’s better to copy your folder path rather than typing it.
- If you have some subfolders and files inside the folder, then use the parameter “/s” in the command to delete it. The command will be as follows:
rmdir /s “folder path”
This will delete all the subfolders and files present in the folder you want to delete.
Like here, the command deleted all the subfolders inside my “TestFolder”.
How To Delete Files Using Command Prompt?
To delete a file in Command Prompt you will have to use the in-built “del” command.
But remember that once you delete a file using the “del” command it will be permanently deleted. You will not find it in the recycle bin.
As you cannot retrieve the deleted files so, be careful while using Command Prompt to delete your files.
Now here is how to delete a file using Command Prompt:
- Open an elevated Command Prompt window.
- Enter the following command and press the enter button. Make sure to replace “your file path” with the entire file path:
del “your file path”
Look at the above image. Here, I have deleted a file named ‘TestFile’ that was saved on my desktop. The command has deleted my file from the storage.
- You can also customize your command. Like if you want to be asked for a confirmation before deleting a particular file, add the parameter “/p”. Check the picture attached below:
After adding the parameter, the file will be deleted after taking your confirmation. So, confirm your action when prompted.
How To Force Delete A File Using Command Prompt?
If you cannot delete a read-only file from your system using other ways you can use Command Prompt to force delete the file.
Here is how to do it:
- Open an elevated Command Prompt window and add the “/f” parameter to your command and press the Enter Key:
This will permanently delete the read-only file from your system.
How To Delete Files That End With The Same Word?
If you have files ending with the same word then you can delete all the files using Command Prompt.
Like, if you have 5 files in your system with the ending word “test”, then add “test*” after del, like:
del “test*”
Now suppose you have some files saved in jpg format and you want to delete all of them. Then add “.jpg” with the del command:
del *.jpg
Make sure to replace .jpg with your file extension. This will select all your jpg files in the current folder and delete those.
Final Words
So that was how to use cmd to delete folders and files from your system permanently.
If you have found this article convenient to serve the purpose, leave us feedback in the comments section provided below.