How to Delete a File Using Command Prompt

This wikiHow teaches you how to delete a file from your PC's desktop by using a command in Command Prompt. Locate your file. If you know where the file is, you can navigate to it by simply opening the appropriate folder. For example, if...

Part 1 of 2:

Preparing Your File for Deletion

  1. Picture 1 of How to Delete a File Using Command Prompt
    Locate your file. If you know where the file is, you can navigate to it by simply opening the appropriate folder. For example, if you're trying to delete a picture or a text file, you will likely want to look in the default "Documents" folder, which typically holds those file types.
    1. If you don't know where your file is, type its name into the Start search bar, right-click the file when it pops up, and click Open file location to go directly to the file.
  2. Picture 2 of How to Delete a File Using Command Prompt
    Click and drag your file onto the desktop. Doing so will make the deletion process easier as you won't have to change the deletion location from within Command Prompt.
    1. The exception to this rule is if you're trying to delete a file from the "System32" folder, which is Windows' system files folder. If that's the case, leave your file there.
  3. Picture 3 of How to Delete a File Using Command Prompt
    Right-click your file. This will prompt a drop-down menu.
  4. Picture 4 of How to Delete a File Using Command Prompt
    Click Properties. It's at the bottom of the drop-down menu.
  5. Picture 5 of How to Delete a File Using Command Prompt
    Look at the file extension. The file's extension is listed near the top of the "General" tab in the "Properties" window, to the right of the "Type of file:" text. You'll need to know your file's extension in order to delete it using Command Prompt. Common extensions include the following:
    1. .txt - Text files (files made in Notepad).
    2. .docx - Microsoft Word files.
    3. .jpg or .png - Picture files.
    4. .mov, .wmv, .mp4 - Video files.
    5. .mp3, .wav - Sound files.
    6. .exe - Executable files (e.g., a setup file).
    7. .lnk - Shortcut files. Deleting a shortcut will not remove the attached program from your computer.
  6. Picture 6 of How to Delete a File Using Command Prompt
    Write down the file extension. Once you know the file extension, you're ready to open and use Command Prompt.
Part 2 of 2:

Deleting the File with Command Prompt

  1. Picture 7 of How to Delete a File Using Command Prompt
    Open Command Prompt. In this case, you'll want to avoid the "Administrator" (or "Admin") version of Command Prompt unless you're deleting a file in the "System32" folder. You can open Command Prompt in a variety of ways depending on your version of Windows:
    1. Hold down Win and press X, then click Command Prompt above the Start button.
    2. Right-click the Start button in the bottom-left corner of the screen, then click Command Prompt in the pop-up window.
    3. Type "Command Prompt" into the Start menu search bar (for 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.
    4. Open the "Run" app from the Start menu, type in "cmd", and click OK.
  2. Picture 8 of How to Delete a File Using Command Prompt
    Type in cd desktop and press Enter. Doing so will change the location (or "directory") in Command Prompt to your desktop.
    1. There are other ways you can change the Command Prompt directory if need be.
    2. Opening Command Prompt in "Administrator" mode will change the directory to the "System32" file. For this reason, do not open Command Prompt in "Administrator" unless your file is in the "System32" folder.
  3. Picture 9 of How to Delete a File Using Command Prompt
    Type in del [filename.filetype]. Replace "filename.filetype" with your file's actual name and extension.
    1. For example, a picture file named "icecream" would become icecream.png, a text file named "notes" would become notes.txt, and so on.
    2. For files with spaces in their names, place quotation marks around the entire file name: "I like turtles.jpg" instead of I_like_turtles.jpg or similar.
    3. To delete all files on your desktop that share the same extension (e.g., all text files), type *.filetype where "filetype" is the extension (e.g., *.txt).
  4. Picture 10 of How to Delete a File Using Command Prompt
    Press Enter. You will see a new, blank line appear in Command Prompt. Your file is now gone.
    1. Since the "del" command removes files directly from your hard drive, you won't need to delete the file again from the Recycling Bin.
Update 04 March 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile