Delete a file in Windows cmd

To delete a file in Windows cmd, we use the del batch command. The delete command provides many very useful options to be in control of the deletion process.

How to delete a file with Windows cmd?

The main option that i suggest to use is the deletion confirmation. This way you are able to control one last time which file top delete. Please note that the files deleted with the del command line are not stored in the Recycle Bin. So you cannot restore them.

Make sure you delete the proper file. The delete operation is irreversible.

Delete a file the simple way

To delete one file using the explicit path, without any confirmation prompt, use this command:

del "C:\Folder\file (1).txt"

Delete a file with a confirmation prompt

To delete a file and make sure to double check the filename.

del /p "C:\Folder\file (2).txt"

Then a prompt is displayed:
C:\Folder\file (2).txt, Delete (Y/N)?

Image with screenshot how to delete a file in windows cmd.
Screenshot of Windows command prompt of file deletion a file in cmd.

Delete a file with no confirmation

To force the deletion with no prompt at all use the delete in quiet mode:

del /q "C:\Folder\file (3).txt"

Delete a read only file

When deleting a read only file, the command prompt displays this :

Access is denied.

To force deletion of a read only file, use the del /f option:

del /q "C:\Folder\file (3).txt"

To conclude, the “del /p” option is definitely the best option to make sure you do not delete a file by mistake. Use it when only when deleting specific and targeted files.

Check out how to copy a file to another folder in command line.