Friday 5 January 2018

How to delete a file, directory, or folder

How to delete a file, directory, or folder

If you are looking to delete a file, directory, or folder, the steps vary depending 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
  • MS-DOS and Windows command line
  • Linux, Unix, and variant
  • macOS
  • Microsoft Windows 3.X

How to delete files in Microsoft Windows

 
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 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 done to delete multiple files or folders if you select more than one file.

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.

Tip: You can hold down the Shift key while pressing the delete key to prevent the files being deleted from going to the Recycle Bin.


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

Some files may only be deleted with administrator permissions. To delete these files, you would need to have administrator rights 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 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.

Cannot delete file because it's being used by another person or program.
 

Windows command line

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

Uninstalling a program
See our uninstalling a program steps for help with uninstalling (deleting) software programs from the computer.

How to restore a deleted file or folder


If you've deleted a file by mistake you can see our steps on how to restore a deleted file page for further information on recovering a deleted file.

How to delete files in MS-DOS and the Windows command line

 
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. If you are new to the command line you may also want to go through our How to use the Windows command line (DOS) tutorial.


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 file name including the file extension.

Delete multiple files

You can also use wildcards if you want to delete multiple files as shown in the example below.

del *.txt

In the above example, this command would delete all files that end with a .txt file extension.

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

Note: If the directory is full or has other sub directories, you will 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 deltree command or rmdir command for additional examples and switches.


Deleting a subdirectory

If you want to delete a directory within another directory (subdirectory), you can use a command similar to the example below.

rmdir example\test

In the above example, the "test" directory within the "example" directory would be deleted. You could also use the cd command to change the directory to the example directory and then delete the "test" directory using our first example shown above.

How to delete a directory or file name with a space


To delete a directory or file name with a space in the name, you must surround the directory or file name with quotes as shown below.

del "my example file.txt"

rmdir "my example directory"


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.


How to delete files in Linux, Unix, and other variants


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 file name including the file extension.

Delete multiple files

You can also use wildcards if you want to delete multiple files as shown in the example below.

rm *.txt
In the above example, this command would delete all files that end with a .txt file extension.

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.

Deleting a subdirectory

If you want to delete a directory within another directory (subdirectory) you can use a command similar to the example below.

rmdir example\test

In the above example, the "test" directory within the "example" directory would be deleted. You could also use the cd command to change the directory to the example directory and then delete the "test" directory using our first example shown above.

How to delete a directory or file name with a space

To delete a directory or file name with a space in the name you must surround the directory or file name with quotes as shown below.

rm "my example file.txt"

rmdir "my example directory"


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.





How to delete files on macOS


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: Users not familiar with Apple macOS 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.

Delete file or folder by right-clicking it, and choosing Delete


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.

Terminal

To delete files or directories in the Terminal command line, use the rm command.

How to delete files on Microsoft Windows 3.X


File Manager

Open File manager
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 deleting a directory in MS-DOS.

0 comments:

Post a Comment

Good Morning Beautiful

Do you know????

Do you know????
/