Del Command

Examples, options, switches, and more

In This Article

Jump to a Section

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 in Windows 10

This command is the exact same as the erase command.

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.

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 Options
Item Explanation
/p Prompts for confirmation before deleting each file.
/f Force deletes read-only files.
/s Deletes the specified files from all the subdirectories.
/q Quiet mode; suppresses prompts for delete confirmations.
/a Deletes files based on one of the following attributes:

r = Read-only files
h = Hidden files
i = Not content indexed files
o = Offline files
s = System files
a = Files ready for archiving
l = Reparse points
/? Use the help switch with the del command to show detailed help about the command's several options. Executing del /? is the same as using the help command to execute help del.

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.

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 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.

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:rDOCX 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.

Was this page helpful?