How to Delete Files and Folders Using Command Prompt on Windows 10 (2024)

Quick Links

  • Table of Contents

  • Delete Files with Command Prompt on Windows 10

  • Delete Folders with Command Prompt on Windows 10

  • Various Uses of the Del Command

If you prefer command-line methods, Windows 10 offers a couple of commands to help you delete your files and folders from a Command Prompt window. We'll show you how to perform this deletion.

Table of Contents

  • Delete Files with Command Prompt on Windows 10
  • Delete Folders with Command Prompt on Windows 10
  • Various Uses of the Del Command

Delete Files with Command Prompt on Windows 10

To delete files (not folders) from Command Prompt on Windows 10, you can use the built-in del command. This command helps you remove the specified files from your PC.

Know that the del command deletes the specified file without moving it to the Recycle Bin. This means you can't retrieve your file once it's been deleted.

To use it, first, open Command Prompt. Do this by opening the Start menu, searching for "Command Prompt", and clicking "Run as Administrator" on the right of the search results.

How to Delete Files and Folders Using Command Prompt on Windows 10 (1)

In the "User Account Control" prompt that appears, click "Yes."

You now have a Command Prompt window open. Here, type the following command, replacing PATH with the full path to the file you want to delete. Then press Enter.

del PATH

For example, to delete a file named "MyFile.txt" placed on your desktop, use the following command replacing username with your own username:

del "C:\Users\username\Desktop\MyFile.txt"

And your specified file is now deleted from your storage!

To customize your deletion process, you can use a couple of parameters that the del command offers.

For instance, you can add the /p parameter to the command to get Command Prompt to ask for your confirmation before deleting a file. Similarly, you can add the /f parameter to the command to force delete your read-only files.

Here's what the above command looks like when paired with the /p parameter:

del /p "C:\Users\username\Desktop\MyFile.txt"
How to Delete Files and Folders Using Command Prompt on Windows 10 (3)

Related: How to Show Hidden Files and Folders in Windows

Delete Folders with Command Prompt on Windows 10

To delete folders (also called directories) on your PC, use Windows' built-in rmdir command. This command helps you delete folders as well as their subfolders and the files inside them.

Know that the rmdir command removes folders without moving them to the Recycle Bin. You can't restore your folders once they have been deleted with this command.

To use this command, open a Command Prompt window. Do this by opening the Start menu, searching for "Command Prompt", and clicking "Run as Administrator" on the right of the search results.

How to Delete Files and Folders Using Command Prompt on Windows 10 (4)

In the Command Prompt window that opens, type the following command replacing PATH with the full path to the folder you want to delete. Then press Enter.

Make sure that the folder you're deleting doesn't contain any files or folders. If the folder is not empty, use the second command given below to delete your folder.

rmdir PATH

For example, to delete a folder named "MyFolder" on your desktop, use the following command replacing username with your own username:

rmdir "C:\Users\username\Desktop\MyFolder"
How to Delete Files and Folders Using Command Prompt on Windows 10 (5)

And the command will get the specified folder removed from your PC!

If the folder you want to delete contains any files or folders in it, add the /s parameter to the command and this will remove your folder including all its subfolders and files within them.

rmdir /s "C:\Users\username\Desktop\MyFolder"
How to Delete Files and Folders Using Command Prompt on Windows 10 (6)

And that's all.

Various Uses of the Del Command

With the del command, you can use your creativity to delete your files in various ways. For example, you can remove certain types of files, remove only the files that have a certain word in their names, and so on.

For example, to delete all the PNG files in your current folder in Command Prompt, you can use the following command:

Feel free to replace ".png" with any file extension you want to delete.

del *.png
How to Delete Files and Folders Using Command Prompt on Windows 10 (7)

This command selects all PNG files in the current folder and deletes them.

Another creative use of the del command is to delete files that contain a certain word in their names. For example, to delete all files whose names start with "word", you'd use the following command:

Add the asterisk before the word to delete all files that end with your specified word.

del "word*"
How to Delete Files and Folders Using Command Prompt on Windows 10 (8)

Finally, if you'd like to remove all files from the current folder, use the following command:

del *.*
How to Delete Files and Folders Using Command Prompt on Windows 10 (9)

And that's how you delete files and folders with Command Prompt. Very handy!

Deleting files with these methods is certainly not as intuitive as using the graphical methods, but it's good to have these methods just in case you need them.

On a related note, did you know you can make Windowsskip the Recycle Binwhile deleting files?

Related: How to Skip the Recycle Bin for Deleting Files on Windows 10

  • Features
  • Windows 10
  • PC Optimization

Your changes have been saved

Email Is sent

Please verify your email address.

You’ve reached your account maximum for followed topics.

Manage Your List

Follow

Followed

Follow with Notifications

Follow

Unfollow

Readers like you help support How-To Geek. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.

How to Delete Files and Folders Using Command Prompt on Windows 10 (2024)

References

Top Articles
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 5762

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.