How to Delete a File Using Command Prompt

Table of contents:

How to Delete a File Using Command Prompt
How to Delete a File Using Command Prompt
Anonim

The following article teaches you how to delete files on a desktop computer through a command executed via "Command Prompt".

Steps

Part 1 of 2: Preparing the File for Deletion

Delete a File Using Command Prompt Step 1
Delete a File Using Command Prompt Step 1

Step 1. Locate the file

If you know its location, just browse to the location via the folder directory. For example, if the file in question is a photo or a document, it's likely to be in the “Documents” folder, which usually contains these types of files.

If the location of the file is unknown, enter its name in the search bar located in the "Start" menu. Then right-click on the file and select “Open file location” to go straight to the folder where it is located

Delete a File Using Command Prompt Step 2
Delete a File Using Command Prompt Step 2

Step 2. Click and drag the file to the "Desktop"

This way, the deletion process will become easier as it will not be necessary to change the location from the "Command Prompt".

If the file in question is in the “System32” folder, which is the Windows system files folder, leave it there

Delete a File Using Command Prompt Step 3
Delete a File Using Command Prompt Step 3

Step 3. Right-click on the file to open the dropdown menu

Delete a File Using Command Prompt Step 4
Delete a File Using Command Prompt Step 4

Step 4. Select the Properties option located at the bottom of the menu

Delete a File Using Command Prompt Step 5
Delete a File Using Command Prompt Step 5

Step 5. Check the file extension

It will be listed at the top of the "General" tab located to the right of the "File type:" text within the "Properties" window. You will need to know the file's extension in order to delete it using Command Prompt. The following extensions are the most common:

  • .txt: text files (saved in Notepad).
  • .docx: Microsoft Word files.
  • -j.webp" />
  • .mov,.wmv,.mp4: video files.
  • .mp3,.wav: music files.
  • .exe: executable files (eg an installation file).
  • .lnk: shortcut files (deleting a shortcut will not remove the program from your computer).
Delete a File Using Command Prompt Step 6
Delete a File Using Command Prompt Step 6

Step 6. Write down the file extension

Once you know the file's extension, the "Command Prompt" can be used to delete it.

Part 2 of 2: Deleting a File with "Command Prompt"

Delete a File Using Command Prompt Step 7
Delete a File Using Command Prompt Step 7

Step 1. Run "Command Prompt"

In this case, try to avoid the "Administrator" (or "Admin") mode of the "Command Prompt", unless the file is located in the "System32" folder. The terminal can be run in different ways, depending on the Windows version:

  • Press the ⊞ Win and X keys, then click on the “Command Prompt” located above the “Start” button.
  • Right-click the "Start" menu button located in the lower left corner of the screen, then click "Command Prompt" in the window that opens.
  • Type "Command Prompt" in the "Start" menu search bar (in Windows 8, hover your mouse in the upper right corner of the screen and click the magnifying glass) and then click the "Command Prompt" icon when it appear.
  • Open the "Run" application from the Start menu, type "cmd" and click "OK."
Delete a File Using Command Prompt Step 8
Delete a File Using Command Prompt Step 8

Step 2. Type desktop cd and press ↵ Enter

This way, the location (or "directory") in the "Command Prompt" will be changed to the "Desktop".

  • If necessary, there are other ways to change the directory via "Command Prompt".
  • Opening the "Command Prompt" in "Administrator" mode will change the directory to the "System32" file. For this reason, do not open the terminal in "Administrator" mode unless the file is located in the "System32" folder.
Delete a File Using Command Prompt Step 9
Delete a File Using Command Prompt Step 9

Step 3. Type del [filename.file extension]

Replace “filename.fileextension” with the name and extension of the file to be deleted.

  • For example, an image file named “ice cream” would be ice cream-p.webp" />
  • For files with spaces between names, enclose the entire name in quotation marks, as in: "I like turtles.jpg" instead of I like turtles-j.webp" />
  • To exclude all files on the desktop that have the same extension (for example, all text files), enter *fileextension, where in “fileextension” the extension (for example, *.txt) should be typed.
Delete a File Using Command Prompt Step 10
Delete a File Using Command Prompt Step 10

Step 4. Press ↵ Enter to finish

This way, the file will be deleted and a new blank line will be displayed in the "Command Prompt".

Since the "del" command directly removes files from the hard drive, it will not be necessary to delete them again in the "Recycle Bin"

Tips

It is recommended to use the system file manager to delete files and use the "Command Prompt" only when it is necessary to delete files that require a more practical approach

Notices

  • The computer may stop working if a system file is deleted.
  • Files deleted via "Command Prompt" will not be sent to "Recycle Bin".

Popular by topic