How to Delete File From Cmd Windows 10

How to delete a file, directory, or folder

Updated: 07/06/2021 by Computer Hope

Delete file image

Now and then, it is a good idea to clean up your drives and delete duplicate photos, documents, temporary files, shortcuts, videos, or other unneeded or unused files or folders. The steps to delete a computer file, directory, or folder vary on the method you want to use and 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 an unwanted file or folder (directory) from a hard drive or external disk drive using many different methods. Below are the more common methods for deleting a file or folder in Microsoft Windows.

Note

Users not familiar with Windows should realize that if you delete a folder or directory, all files and folders in that folder or directory are deleted.

Delete key

Locate the item you want to delete, highlight it by left-clicking the file or folder with your mouse once, and press the Delete key. You can browse the location of the file or folder using My Computer or Windows Explorer.

Tip

You can delete multiple files or folders by holding down the Ctrl key and clicking each file or folder before pressing Delete.

Tip

You can hold down the Shift key while pressing the Delete key to prevent files from going to the Recycle Bin when deleted.

Right-click delete a file in Windows

Delete file or folder by right-clicking

Open My Computer or Windows Explorer. We recommend you make sure the directory or folder is empty before proceeding, unless you intend to delete everything in it. Locate the file or folder you want to delete and right-click it. Choose the Delete option from the pop-up menu.

How to delete from the local disk

Important

The local disk contains files and folders that are imperative for your computer to run correctly. Unless you know what you are deleting, please do not delete any files from this section.

Open My Computer or Windows Explorer. On the left side of the screen, click This PC. On the right side of the screen, locate and double-click the local disk (usually C: or D:). Double-click the folder containing the file you want to delete. Select the file or folder you want to delete, click File in the top menu bar, and select Delete.

How to delete from an external drive

To delete from a USB flash drive, floppy drive, memory card, or external hard drive, open My Computer or Windows Explorer. On the left side of the screen, click This PC. On the right side of the screen, locate and double-click the drive, which is labeled as USB, flash drive, external hard drive, or the manufacturer's name. Select the file or folder you want to delete, click File in the top menu bar, and select Delete.

Delete from the file menu

Open My Computer or Windows Explorer. 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 Alt key to make the menu bar visible, including the file menu.

Problems during delete

Some documents 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 read-only, meaning the user can only open it for viewing and not modify or delete it. When trying to delete a read-only file, you get a message stating the file is write-protected and cannot be deleted. You need to modify or write permissions to delete the file.

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 delete the affected file or folder.

  • Unable to delete file: being used by another person or program.
  • How do I remove a virus and malware from my computer?

Windows command line

See the MS-DOS and Windows command line section below 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 uninstall software in Windows.

How to restore a deleted file or folder

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

  • How to recover missing, lost, or deleted files.

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 is not sent to the Windows Recycle Bin.

Before you follow any of the steps below, 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 read through the following pages first.

  • How to get to an MS-DOS prompt or Windows command line.
  • How to use the Windows command line (DOS).
del command

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 to use this command.

del example.txt

As seen in the example above, when deleting a file, you need to enter the full file name, including the file extension.

Tip

The del command can delete any file.

Delete multiple files

You can also use wildcards to delete multiple files or a group of files, as shown in the example below.

del *.txt

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

Tip

The del command can delete any file extension.

Directory

MS-DOS users can delete directories (dir) 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 to use this.

rmdir example

Note

If the directory is full or has other subdirectories, you 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.

  • How to delete files in MS-DOS without a prompt.

Deleting a subdirectory

To delete a subdirectory, subfolder, folder within a folder, or directory within a directory, use a command similar to the example below.

rmdir example\test

In the example above, the "test" directory in the "example" directory is 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.

Tip

The rmdir command can delete any file.

  • How to use the Windows command line (DOS).

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

rm command

Files

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

rm example.txt

As seen in the example above, when deleting a file, you need to enter the full file name, including the file extension.

Tip

The rm command can delete any file.

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 example above, this command would delete all files with a .txt file extension.

Tip

The rm command can delete any file of file extensions.

Directory

Linux and Unix users can delete folders through the console with the rmdir command. See this page for additional information about this command. Below is an example of how to use this command.

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

To delete a directory in another directory (subdirectory), use a command similar to the example below.

rmdir example\test

In the example above, the "test" directory in 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 examples above, we are deleting the file named "my example file.txt" with quotes surrounding the complete file name and extension. We are also removing the "my example directory" directory.

Tip

The rmdir command can delete any file.

  • How do I remove a full directory in Linux?
  • Linux and Unix shell tutorial.

How to delete files on macOS

Apple macOS users can delete photos, documents, or other files or folders (directory) on their Mac 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 it deletes all the files in a folder if you delete that folder.

Delete key

The delete key on the keyboard by itself does not delete a file or folder on macOS. To delete a file or folder, press and hold Command, then press the delete key. You can browse to the location of the file or folder using Finder.

Right-click and choosing Move to Trash

Open Finder, locate the file or folder you want to delete, and right-click the file or folder. In the right-click menu that appears, click the Move to Trash option.

Delete from the file menu

Open Finder, locate and select the file or folder you want to delete. Click File in the top menu bar and select Move to Trash.

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

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

MS-DOS

See the MS-DOS user section above for information about deleting a directory in MS-DOS.

How to Delete File From Cmd Windows 10

Source: https://www.computerhope.com/issues/ch000743.htm

0 Response to "How to Delete File From Cmd Windows 10"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel