Deleting a file with Command Prompt

Author: Eugene Taylor
Date Of Creation: 8 August 2021
Update Date: 1 July 2024
Anonim
How to permanantly delete any undeletable file or folder using command prompt
Video: How to permanantly delete any undeletable file or folder using command prompt

Content

This wikiHow teaches you how to delete a file from your PC Desktop using the Command Window.

To step

Part 1 of 2: Prepare the file you want to delete

  1. Find your file. If you know where the file is, you can get to it by just opening the appropriate folder. For example, if you try to delete an image or text file, you may find it in the default "Documents" folder, which usually contains such file types.
    • If you don't know where a file is, type its name in the search bar of the Start menu, right-click the file when it is displayed, then click Open file location to go directly to the file.
  2. Click and drag your file onto the Desktop. This makes removing them much easier, as you don't have to change the location in the Command Window.
    • The exception to this rule is to delete a file from the "System32" folder, which is a Windows system folder. If so, leave the file there.
  3. Right click on the file. This will open a submenu.
  4. Click on Properties. You can find this at the bottom of the submenu.
  5. Look at the file extension. The file extension is located near the top of the "General" tab in the "Properties" window to the right of the "File type:". You will need to know the extension of your file in order to remove it with Command Prompt. Some well-known extensions are:
    • .txt - Text file (files created with eg Notepad).
    • .docx - Microsoft Word files.
    • .webp or .png - Image files.
    • .mov, .wmv, .mp4 - Video files.
    • .mp3, .wav - Sound files.
    • .exe - Executable files (e.g. a setup file).
    • .lnk - Shortcuts. Removing a shortcut will not remove the associated program from your computer.
  6. Make a note of the file extension. If you know the file extension, you can use Command Prompt.

Part 2 of 2: Deleting a file with Command Prompt

  1. Open the Command window. In this case, you should avoid the "Administrator" (or "Admin") version of the Command Prompt unless you delete a file in the "System32" folder. You can open Command Prompt in several ways, depending on your version of Windows:
    • Keep ⊞ Win and press X, after which you press Command Prompt clicks above the Start button.
    • Right-click the Start button in the lower left corner of the screen, then click Command Prompt in the pop-up window.
    • Type "Command Prompt" in the search bar of the Start menu (in Windows 8, hover your mouse in the top right corner of the screen and click the magnifying glass), then click the "Command Prompt" icon when it appears.
    • Open the "Run" app from the Start menu, type "cmd" and click OK.
  2. Type cd desktop and press ↵ Enter. This will change the location (or "directory") in the Command Prompt to your Desktop.
    • There are other ways to change the directory in Command Prompt, if needed.
    • Opening the Command Prompt in "Administrator" mode will change the directory to "System32". Therefore, you should choose to open the Command Prompt in "Administrator" mode, unless your file is located in the "System32" folder.
  3. Type del [filename.filetype]. Replace "filename.filetype" with the name and extension of the file.
    • For example, an image file named "icecream" would then be icecream.png, a text file becomes "notes" notes.txt, etc.
    • For files with spaces in the name, put quotation marks around the full file name: "I like turtles.webp" instead of I_like_turtles.webp or the like.
    • To delete all files on your Desktop with the same extension (e.g. all text files), type *. filetype where "filetype" is the extension (eg. *. txt).
  4. Press ↵ Enter. You will see a new blank line appear in the Command window. The file has disappeared.
    • Since the "del" command deletes files directly from your hard drive, you don't have to delete it from the Recycle Bin as well.

Tips

  • It is best to use your system's file manager to delete files and only use Command Prompt when you need to delete files that are more difficult to delete.

Warnings

  • If you delete a system file, your computer may stop working.
  • By using Command Prompt to delete files, you no longer have anything to do with the Recycle Bin.