The del command is a Command Prompt command used to delete files. Various command options are available so that you can remove files that have a certain file extension, delete every file in a folder, get rid of only the files with certain file attributes, and more.
Unlike deleting files normally, data removed with the del command doesn’t end up in Recycle Bin.
Del Command Availability
The del command is available from within the Command Prompt in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP operating systems.
This command is the exact same as the erase command.
It can also be used in Command Prompt in the Advanced Startup Options and System Recovery Options repair/recovery menus.
In Recovery Console in Windows XP and Windows 2000, the delete Recovery Console command can be used instead.
Del Command Syntax
del [/p] [/f] [/s] [/q] [/a[:]] filename [/?]
The availability of certain del command switches and other command syntax might differ from operating system to operating system. Brush up on how to read command syntax if you’re not sure how to interpret the syntax as it’s shows above or described in the table below.
Del Command Examples
Here are some examples showing how you can use the command:
Delete File in Specific Folder
del c:\windows\twain_32.dll
In the above example, the del command is used to remove twain_32.dll located in the C:\Windows folder.
Delete File From Current Folder
del io.sys
Here, the command has no path information specified, so the io.sys file is deleted from whatever directory you typed the command from.
For example, if you type del io.sys from the C:> prompt, the io.sys file will be deleted from C:.
Delete All EXE Files
del C:\Users\Tim\Downloads*.exe
This one removes all EXE files from the Tim user’s Downloads folder. The file extension could be replaced with * to delete every file from that folder.
Delete Every Archived File
del /a:a .
Use this del command to delete every archived file in the current working directory. Similar to the io.sys command above, this one would execute on whatever folder Command Prompt is set to.
Notice there isn’t a space after Downloads. Adding a space would break the command and tell Windows to erase the Downloads folder instead of just the EXE files. Because the del command doesn’t remove folders, it would erase every file from it, including not only EXE files but also images, documents, videos, etc.
Delete By Attribute and Extension
del /q /a:r C:\Users\Tim\Documents*.docx
To combine a few of the del switches, consider this command which will delete every read-only (/a:r) DOCX file from the user’s Documents folder, but will do so in quiet mode (/q) so that you’re not asked to confirm it.
Delete Files From Subfolders
del /s C:\Users\Tim\Documents\Adobe*.*
This command will delete every file (.) from every folder (/s) inside the Adobe folder in the user’s Documents directory. The folders will remain, but every file will get removed.
However, in this example, you’ll be prompted to enter Y for each file to confirm that you do, in fact, want to delete each one. To avoid that, if you’re sure you want to delete every single file, you can add the /q switch before or after the /s switch to run the command in quiet mode.
Just like with the DOCX example above, the wildcard (.) in this command can be changed to anything to remove only those files. Use *.MP4 for MP4s, *.MP3 for MP3s, etc.
Del Related Commands
The erase command is identical to the del command, so either can be used with the same result. In other words, you can replace “del” with “erase” in any of the command examples above without interrupting the instructions.
The command forfiles is sometimes used with the del command to remove files that are so-many days old. For example, you might want to delete files that are older than a month in a specific folder, something you can do with forfiles and del but not with just the del command itself.
In Windows XP and newer versions of Windows, rmdir is used to erase a whole folder, while deltree is used for the same purpose in operating systems older than Windows XP.
In MS-DOS, the undelete command is used to restore files that were deleted with the delete command. To undo the del command in newer versions of Windows, try a file recovery program.
Get the Latest Tech News Delivered Every Day
Copy Command
Rename Command
How to Restore Deleted Files From the Recycle Bin
35 Best Free Data Destruction Software Programs
Eraser v6.2.0 Review
Vol Command Examples and Options
Net Send Command
Xcopy Command
More Command
How to Redirect Command Output to a File
8 Best Free Disk Space Analyzer Tools
Sfc Command (System File Checker)
32 Best Free File Shredder Software Programs
How to Change the Windows Startup Sound
Net Command
Command Prompt: What It Is and How to Use It
Facebook
Twitter
Hit Refresh on Your Tech News
About Us
Privacy Policy
Editorial Guidelines
Terms of Use
Careers
Advertise
Contact
EU Privacy
NEWS
HOW TO
FEATURES
ABOUT US