How to delete a file or folder using cmd in Windows 10 or Windows 11

How to delete a file or folder using cmd in Windows 10 or Windows 11

You can easily delete your files or folders in your PC. Here's how:

  • Use the del command to delete individual files from your PC.
  • To delete entire folders with the Command prompt, use the rmdir command.

 

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 instead would like to place your bets on the Command prompt, then you’re at the right place.

Follow the steps below, and you’ll be able to delete specific files and folders in your Windows with ease.

How to delete a Windows file or folder with Command prompt

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:

del fileName.type

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:

del deleteME.txt

For instance, we've deleted a .dll file named ucrtbase. Here's what it looks like:

command prompt

That’s it. Do this and your Windows file will be deleted.

Delete your folders with Command prompt

To delete your folders on Windows, type in the following command in the Command prompt and hit Enter:

rmdir filename.type

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

command prompt

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 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.

Share This Post:

Older

May's Windows 11 Patch Tuesday Update could cause authentication issues

We're back! Don't miss OnPodcast on Sunday for a recap of week's biggest Microsoft news

Newer