How To Delete File Using CMD
How To Delete File Using CMD
Enter the command prompt (Start-> Run-> Cmd) and enter ‘del /f filename’, where ‘filename’ is
the name of the file or files (you can specify multiple files using commas) you want to delete
1. 1
Open Command Prompt. In this case, you'll want to avoid the "Administrator" (or
"Admin") version of Command Prompt unless you're deleting a file in the "System32"
folder. You can open Command Prompt in a variety of ways depending on your version
of Windows:
Hold down ⊞ Win and press X , then click Command Prompt above the Start button.
Right-click the Start button in the bottom-left corner of the screen, then click Command
Prompt in the pop-up window.
Type "Command Prompt" into the Start menu search bar (for Windows 8, hover your
mouse in the top-right corner of the screen and then click the magnifying glass), then
click the "Command Prompt" icon when it appears.
Open the "Run" app from the Start menu, type in "cmd", and click OK.
2. 2
Type in c d d e s k t o p and press ↵ Enter . Doing so will change the location (or
"directory") in Command Prompt to your desktop.
There are other ways you can change the Command Prompt directory if need be.
Opening Command Prompt in "Administrator" mode will change the directory to the
"System32" file. For this reason, do not open Command Prompt in "Administrator"
unless your file is in the "System32" folder.
3. 3
Type in d e l [ f i l e n a m e . f i l e t y p e ] . Replace "filename.filetype" with your file's
actual name and extension.
For example, a picture file named "icecream" would become i c e c r e a m . p n g , a text file
named "notes" would become n o t e s . t x t , and so on.
For files with spaces in their names, place quotation marks around the entire file
name: " I l i k e t u r t l e s . j p g " instead of I _ l i k e _ t u r t l e s . j p g or similar.
To delete all files on your desktop that share the same extension (e.g., all text files),
type * . f i l e t y p e where "filetype" is the extension (e.g., * . t x t ).
4. 4
Press ↵ Enter . Doing so will , and you'll see a new, blank line appear in Command
Prompt. Your file is now gone.
Since the "del" command removes files directly from your hard drive, you won't need to
delete the file again from the Recycling Bin.
DEL /F /Q /A C:\Users\Lovejeet\Desktop\infected.txt
RD /S /Q C:\Users\Lovejeet\Desktop\Folder