HomeHow ToHow to Delete a File Using Command Prompt

How to Delete a File Using Command Prompt


There are many simple methods to delete a file in Windows, and using command prompt for this process might be an unconventional way.

You can simply go to windows explorer and hit the delete button to remove a file or folder from your computer. However, this method can sometimes take an eternity to remove a large number of contents from your computer.

In that case, the command prompt can come in super handy. Plus, it can also help you tackle restrictions while deleting some restricted files (unwanted system and junk files).

However, keep in mind that the command to delete a file is final. The deleted items won’t go to the recycle bin, and it is not possible to recover data after utilizing these commands.

So, make sure you only erase those files which you genuinely want to remove from your computer.

Also read: How to Delete a Folder Using Command Prompt

How to delete a file using CMD

  1. Click the Start button.
  2. In the Search box, type ‘cmd’.
  3. Right-click on Command Prompt, and then click Run as administrator.
Run CMD as administrator

4. Now type the filename with extension followed by its full path, which you want to delete. In case you don’t know what its extension is, right-click on the file and select properties (it will show you its full path with name and file extension).

del d:\jun\screenshot.png

Or you can try force deleting a file when Windows locks it, and it says the file is in use by a program. Use the following command to remove a restricted file.

del /f filename

5. Here, ‘del’ is the delete command, ‘d:\jun\’ would be the path to my file, and ‘screenshot.png’ is the file that I want to delete.

Same goes with the force deletion method, just replace ‘filename’ with your actual filename without an apostrophe (‘). So, change it accordingly to the file that you want to delete.

6. Hit Enter after you put in the command and the file should be deleted by now.

Now you can delete files on your computer using Command prompt. However, keep in mind that files deleted using the command line are not recoverable. If you have any doubts, then make a backup first.


Please enter your comment!
Please enter your name here

Featured Posts

Most Popular