How to Delete Files in Windows via Batch File: 13 Steps

Table of contents:

How to Delete Files in Windows via Batch File: 13 Steps
How to Delete Files in Windows via Batch File: 13 Steps

Video: How to Delete Files in Windows via Batch File: 13 Steps

Video: How to Delete Files in Windows via Batch File: 13 Steps
Video: Insert Image Using Mail Merge From Excel to Word Document 2024, May
Anonim

Want to delete files in a folder with one click? Or, are you an application developer looking to use a free way to delete files as part of a program? Just read this wikiHow article, and follow the steps!

Before Starting

  1. Open the Run dialog box by pressing Windows + R keys simultaneously, then enter "explorer" and press Enter.
  2. While the Windows Explorer window is active, press Alt.
  3. Click Tools > Folder Options
  4. In the Folder Options dialog box, click the View tab.
  5. Uncheck the "Hide extensions for known file types" option if it is checked.
  6. Click OK.

    Step

    Delete a File in Microsoft Windows Using Batch Files Step 1
    Delete a File in Microsoft Windows Using Batch Files Step 1

    Step 1. Open Notepad by clicking Start > All Programs > Accessories > Notepad

    Delete a File in Microsoft Windows Using Batch Files Step 2
    Delete a File in Microsoft Windows Using Batch Files Step 2

    Step 2. Insert "cd" into the Notepad window (without the quotes)

    Delete a File in Microsoft Windows Using Batch Files Step 3
    Delete a File in Microsoft Windows Using Batch Files Step 3

    Step 3. Find the file or folder that you want to delete

    Right-click the file/folder, then select Properties.

    Delete a File in Microsoft Windows Using Batch Files Step 4
    Delete a File in Microsoft Windows Using Batch Files Step 4

    Step 4. Copy the information in the "Location" field of the "Properties" window

    Delete a File in Microsoft Windows Using Batch Files Step 5
    Delete a File in Microsoft Windows Using Batch Files Step 5

    Step 5. In Notepad, press the space after "cd", then press the quotes and paste the information you have copied

    End the information with quotation marks. For example, if you copy C:\users\Rhoma Rhythm, the information will be pasted as "C:\users\Rhoma Rhythm" (with quotes).

    If you want to delete a file from a specific location, but the file in that location doesn't exist, start at step 3, and enter the file location

    Delete a File in Microsoft Windows Using Batch Files Step 6
    Delete a File in Microsoft Windows Using Batch Files Step 6

    Step 6. Press Enter to start a new line in Notepad

    Delete a File in Microsoft Windows Using Batch Files Step 7
    Delete a File in Microsoft Windows Using Batch Files Step 7

    Step 7. In the new line, enter "del" (without the quotes)

    Step 8. Press space once, then enter the name of the folder or file you want to delete along with its extension (if any)

    Begin and end the file name with quotation marks. For example, if you want to delete the "sugar" folder, enter del "sugar". Or, if you want to delete "young blood.3gp", enter del "young blood.3gp".

    Delete a File in Microsoft Windows Using Batch Files Step 8
    Delete a File in Microsoft Windows Using Batch Files Step 8
    Delete a File in Microsoft Windows Using Batch Files Step 9
    Delete a File in Microsoft Windows Using Batch Files Step 9

    Step 9. At the top of the Notepad window, click File > Save As.

    Delete a File in Microsoft Windows Using Batch Files Step 10
    Delete a File in Microsoft Windows Using Batch Files Step 10

    Step 10. In the Save As window, select the "All Files" option in the "Save as Type" field

    Delete a File in Microsoft Windows Using Batch Files Step 11
    Delete a File in Microsoft Windows Using Batch Files Step 11

    Step 11. In the "File Name" field, enter "filename.bat" (without the quotes)

    Replace "filename" with the name you want.

    Delete a File in Microsoft Windows Using Batch Files Step 12
    Delete a File in Microsoft Windows Using Batch Files Step 12

    Step 12. Click Save.

    Delete a File in Microsoft Windows Using Batch Files Step 13
    Delete a File in Microsoft Windows Using Batch Files Step 13

    Step 13. Locate the folder where you saved the batch file, then double-click the file

    If you follow all the steps above correctly, the file you are referring to will be deleted.

    If you receive the prompt and still want to delete the file, press "Y", then press Enter

    Tips

    • You can use wildcards in batch files. For example, if you want to delete the contents of a folder, use the * sign. If you want to delete all text files with the TXT extension in a folder, enter *.txt as the file name.
    • To delete multiple files at once, repeat the above steps in the same Notepad document.

Recommended: