How do I delete a file, directory, or folder?

DeleteMicrosoft Windows users
MS-DOS and Windows command line users
Linux, Unix, and variant users
Microsoft Windows 3.X users

Microsoft Windows users

Microsoft Windows users can delete a file or folder, also called a directory, using many different methods. Below are the more common methods for deleting a file or folder.

Note: Users not familiar with Windows should realize that if you delete a folder, it will delete all the files and folders within that folder.

Tip: The steps below are for deleting a single file or folder. However, the same steps can be applied to delete multiple files or folders if you select several of them first.

Delete key

The easiest way to delete files and folders is to locate the item you want to delete, highlight it by clicking on the file or folder once, and then press the delete key on the keyboard. You can browse to the location of the file or folder using either My Computer or Windows Explorer.

Right-click delete a file in WindowsDelete file or folder by right-clicking

Open My Computer or Windows Explorer. Locate the file or folder you want to delete and right-click it. Choose the delete option from the pop-up menu.

Delete from File menu

Open My Computer or Windows Explorer, locate the file or folder you want to delete, click File in the top menu bar and select Delete.

Tip: If the File menu is not visible in My Computer or Windows Explorer, press the Alt key to make the menu bar visible, including the File menu.

Problems during delete

Some files and folders may be protected from deletion through encryption or password protection. In this case, you may be asked for a password to decrypt or remove the password protection.

A file may be set as a read-only file, meaning it can only be opened for viewing, but it cannot be modified or deleted. When trying to delete a read-only file, you will get a message stating the file is write protected and cannot be deleted.

Another possible cause of problems with deleting a file or folder is a virus or malware infection. Viruses and malware can prevent files or folders from being modified or deleted. If this is the case, you need to remove the virus or malware infection to be able to delete the affected file or folder.

Windows command line

See the below MS-DOS users section for information about deleting a file or folder at the Windows command line.

MS-DOS and Windows command line users

Note: Keep in mind that any deleted file or directory in MS-DOS will not be sent to the Windows Recycle Bin.

Before any of the steps below can be followed, you must get to an MS-DOS prompt or the Windows command line.

Files

MS-DOS users can delete files using the del command. See this page to get additional information and help with this command. Below is an example of how this command could be used.

del example.txt

As seen in the above example, when deleting a file, you need to enter the full filename including the file extension. You can also use wildcards if you want to delete multiple files.

Directory

MS-DOS users can delete directories in MS-DOS using the deltree command or rmdir command. See either of these links for additional information about these commands. Below is an example of how this could be used.

rmdir example

Linux, Unix, and variant users

Files

Linux and Unix users can delete files through the console by using the rm command. See this page for additional information about this command. Below is an example of how this command could be used.

rm example.txt

As seen in the above example, when deleting a file, you need to enter the full filename including the file extension. You can also use wildcards if you want to delete multiple files.

Directory

Linux and Unix users can delete folders through the console by using the rmdir command. See this page for additional information about this command. Below is an example of how this command could be used.

rmdir example

Tip: Like Microsoft Windows, with Linux and Unix, you can also delete files through the GUI by locating the file and pressing the delete key on the keyboard.

Microsoft Windows 3.X users

File Manager

  1. Open File manager
  2. Locate the folder or file you want to delete, then click File and Delete.

MS-DOS

See the above MS-DOS users section for information about creating a directory in MS-DOS.

Additional information