How do I delete a file, directory, or folder?
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.
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.
Delete file or folder by right-clicking
Delete from File menu
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.
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.
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.
Linux, Unix, and variant users
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.
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.
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
- Open File manager
- Locate the folder or file you want to delete, then click File and Delete.
See the above MS-DOS users section for information about creating a directory in MS-DOS.