How to delete a file, directory, or folder
https://www.computerhope.com/issues/ch000743.htm
Last updated
Was this helpful?
https://www.computerhope.com/issues/ch000743.htm
Last updated
Was this helpful?
Updated: 12/01/2019 by Computer Hope
The steps to delete a computer file, directory, or folder vary on the method you'd like to use, as well as your operating system. To proceed, choose from the list of options below and follow the instructions.
Microsoft Windows users can delete a file or folder (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 , it deletes 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 done to delete multiple files or folders if you .
Locate the item you want to delete, it by clicking on the file or folder once, and press the keyboard . You can browse to the location of the file or folder using either or .Tip
You can delete multiple files or folders by holding down the and clicking each before pressing Delete.Tip
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.
Note
Keep in mind that any deleted file or directory in MS-DOS is not be sent to the Windows Recycle Bin.
The del command can be used to delete any file.
The del command can be used to delete any file extension.
Note
In the above examples, we are deleting the file named "my example file.txt" with quotes surrounding the complete file name and extension and removing the "my example directory" directory.Tip
The rmdir command can be used to delete any file.
The rm command can be used to delete any file.
In the above example, this command would delete all files that end with a .txt file extension.Tip
The rm command can be used to delete any file of file extensions.
Tip
In the above examples, we are deleting the file named "my example file.txt" with quotes surrounding the complete file name and extension and removing the "my example directory" directory.Tip
The rmdir command can be used to delete any file.
Apple macOS users can delete a file or folder (directory) using many different methods. Below are the more common methods for deleting a file or folder.Note
Locate the folder or file you want to delete, then click File and Delete.
You can hold down the while pressing the delete key to prevent the files being deleted from going to the Recycle Bin.
Open or . Locate the file or folder you want to delete and it. Choose the delete option from the .
Open or , locate and select 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 key to make the menu bar visible, including the file menu.
A file may be set as a 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'll get a message stating the file is write-protected and cannot be deleted. You'll need modify or write permissions to be granted to your user account to delete the file.
Some files may only be deleted with administrator permissions. To delete these files, you would need to have on the computer. If you are using a work computer, the technical support staff often are the only users with administrator rights on the computer.
Another possible cause of problems with deleting a file or folder is a or infection. Viruses and malware can prevent files or folders from being modified or deleted. If this is the case, you need to to be able to delete the affected file or folder.
See the below section for information about deleting a file or folder at the Windows command line.
See our steps for help with uninstalling (deleting) software programs from the computer.
If you've deleted a file by mistake, you can see our steps on page for further information on recovering a deleted file.
Before any of the steps below can be followed, you must . If you are new to the command line, you may also want to go through our tutorial.
MS-DOS users can delete files using the . See this page to get additional information and help with this command. Below is an example of how this command could be used.
As seen in the above example, when deleting a file, you need to enter the full including the .Tip
You can also use if you want to delete multiple files as shown in the example below.
In the above example, this command would delete all files that end with a .txt .Tip
MS-DOS users can delete directories in MS-DOS using the or . See either of these links for additional information about these commands. Below is an example of how this could be used.
If the directory is full or has other , you'll get an error message. To delete a full directory, you need to use a switch with the above example. For example, "rmdir example /s" to remove a full "example" directory. See our or for additional examples and switches.
If you want to delete a directory within another directory (), you can use a command similar to the example below.
In the above example, the "test" directory in the "example" directory would be deleted. You could also use the to change the directory to the example directory and then delete the "test" directory using our first example shown above.
To delete a directory or file name with a space in the name, you must surround the directory or file name with as shown below.
Linux and Unix users can delete files through the console by using the . See this page for additional information about this command. Below is an example of how this command could be used.
As seen in the above example, when deleting a file, you need to enter the full file name including the .Tip
You can also use if you want to delete multiple files as shown in the example below.
Linux and Unix users can delete folders through the console by using the . See this page for additional information about this command. Below is an example of how this command could be used.
Like Microsoft Windows, with Linux and Unix, you can also delete files through the by locating the file and pressing the delete key on the keyboard.
If you want to delete a directory within another directory (), you can use a command similar to the example below.
In the above example, the "test" directory in the "example" directory would be deleted. You could also use the to change the directory to the example directory and then delete the "test" directory using our first example shown above.
To delete a directory or file name with a space in the name, you must surround the directory or file name with as shown below.
Users not familiar with Apple macOS should realize that if you delete a , it deletes 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 .
The on the keyboard by itself will not delete a file or folder on macOS. To delete a file or folder hold down the and press the delete key at the same time. You can browse to the location of the file or folder using .
Open Finder and locate the file or folder you want to delete and the file. From the right-click menu that appears, click the Move to Trash option.
Open , locate and select the file or folder you want to delete, click File in the top menu bar and select Move to Trash.
To delete files or directories in the command line, use the .
Open
See the above section for information about deleting a directory in MS-DOS.