Deleting a useless file or folder on Windows is as easy as it gets. Just right-click on the specific file or folder, and select Delete. But, for whatever reason, if you’re not interested in going with the GUI way, but would instead prefer to use the Command prompt, then you’re at the right place.
Follow the steps below, and you’ll be able to delete a file or folder using cmd with ease.
How to delete a file or folder using cmd
The Command prompt has special commands for almost all important tasks. To delete a specific file or folder, use the del command, and you’ll be good to go. First off, launch the Command prompt. Go to the Start menu search bar, type in ‘cmd’ and run the Command prompt as an administrator.
Now, in the Command prompt, change the directory to where your files are located by using the cd command. Then, type in the following command and hit Enter:
Here, you’ve to replace fileName.type with the full name of the file you’d like to delete. For instance, if you want to delete a file named deleteMe.txt located at desktop, then your command will be something like this:
For instance, we’ve deleted a .dll file named ucrtbase. Here’s what it looks like:
That’s it. Do this and your Windows file will be deleted.
Delete your folders with the Command prompt
To delete your folders on Windows, type in the following command in the Command prompt and hit Enter:
Again, as you did above, replace the filename with the full address of your folder. Keep in mind, however, that your deleted files will not be thrown into the Recycle bin, making your restoration a difficult affair.
Moreover, if the folder you want to delete has some other files or folders in it, you can tweak the command a little by adding /s in it. Here’s what the command will look like:
rmdir /s Listary
You’ll then be asked if you’d like to confirm the deletion of your file. Type in Y and hit Enter. Do this and your folders will be deleted instantly.
Deleting files and folders with Command prompt (cmd) in Windows 10 or Windows 11
Deleting your files or folder is just one use case of a Command prompt—there are plenty of others. Hopefully, this article helped you get rid of all the useless files and folders occupying space on your Windows. We also invite you to check out our expert guide which will help learn how to delete files and folders using PowerShell.