Command prompt is one of the most basic yet one of the most powerful tool available in Windows PC. There are several thing which could be done using command prompt like creating hotspot on your Windows PC using command prompt or deleting files and folders. In this article, we will see the later and that is how to delete files and folders using command prompt.
Now why you should use command prompt to delete files and folders from your PC? Files and folders which get infected with malware or virus usually corrupts files and folders, thus making it impossible to delete or remove using the delete option.
There are free software utilities available on the web which will allow you to forcefully remove files and folders from Windows, but the same could also be achieved using command prompt. Here is how you can make use of command prompt in Windows to force delete files and folders.
How to Delete File and Folders using Command Prompt
Note: Before you proceed, make sure that you are following the instructions clearly. A wrong move could delete an important file from your PC.
Step 1: Open command prompt
To open command prompt on Windows:
Press Windows key + R on your keyboard. Type in cmd in run window and hit enter.
Or Click on start button, search cmd and open cmd.exe.
Step 2: Delete Single File using Command Prompt
To delete a Single file enter the following command in the command prompt window and hit enter:
DEL /F /Q /A <File Path>
Example: DEL /F /Q /A C:UsersdellDownloadsDesktopdir_list.txt
In the above example:
/F stand for: Force deletion
/Q stands for: Deletion of read-only files
/A stands for: selecting only files ready for archiving attribute
C:UsersdellDownloadsDesktopdir_list.txt is your file path and dir_list.txt is the file that you want to delete.
Step 3: Delete Folders using Command Prompt
To delete a folder using command prompt, open command prompt and enter the following command and hit enter:
RD /S /Q <Path of the Folder>
Example: RD /S /Q C:UsersdellDownloadsDesktopReceipe
In the above example:
RD stand for: Remove directory
/S stands for: delete sub folder
/Q stands for: Delete directory without confirmation
RD /S /Q C:UsersdellDownloadsDesktopReceipe is folder path and Receipe is the folder that you want to delete.
That’s it. You have successfully deleted a file and a folder using command prompt on Windows.