You can simply go to Windows Explorer, select the file or folder and then hit the delete button to remove it from your computer. However, this method can sometimes take an eternity to remove a large number of files within a directory. 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). Also read: How to download Windows 11 ISO file & do a clean installation 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 impossible to recover data after utilising these commands. So, make sure you only erase those files which you genuinely want to remove from your computer.

How to delete a file using CMD

  1. Now, type the filename with extension followed by its full path, which you want to delete. If you don’t know its extension, right-click on the file and select properties (it will show you its full path with name and file extension). 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.
  2. Here, ‘del’ is the delete command, ‘d:\jun\’ would be the path to my file, and ‘screenshot.png’ is the file I want to delete. The same goes for 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.
  3. Hit Enter after you put in the command, and the file should be deleted by now.

How to delete a folder using CMD

Replace the “folder path” with the actual path of the folder that you want to delete. 5. Hit Enter after you put in the command, and the folder should be deleted by now. Example – rd /s /q “d:\jun” – here jun is the folder I want to delete. Now you can delete anything on your computer using the Command prompt. However, keep in mind that any files or folders deleted using the command line are not recoverable. If you have any doubts, then make a backup first.

Δ

How to delete files and folders using Command Prompt - 28How to delete files and folders using Command Prompt - 34