Del Command

Del command examples, options, switches, and more

Screenshot of the del command options in the Windows 10 Command Prompt
Del Command Options (Windows 10 Command Prompt).

The del command is a Command Prompt command used to delete files. Various del command options are available so that you can delete files that have a certain file extension, delete every file in a folder, delete files with certain file attributes, and more.

Unlike deleting files in Explorer, files deleted with the del command do not end up in Recycle Bin.

Note: The del command is the exact same as the erase command.

Del Command Availability

The del command is available from within the Command Prompt in Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP operating systems.

The del command can also be used in Command Prompt in the Advanced Startup Options and System Recovery Options repair/recovery menus.

Note: The availability of certain del command switches and other del command syntax might differ from operating system to operating system.

Del Command Syntax

del [/p] [/f] [/s] [/q] [/a[:]<attributes>] filename [/?]

Tip: See How to Read Command Syntax if you're not sure how to interpret the del command syntax as it's described above or in the list below.

  • /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:<attributes> = Deletes files based on one of the following attributes:
  • /? = Use the help switch with the del command to show detailed help about the command's several options.

Note: In Recovery Console in Windows XP and Windows 2000, the delete Recovery Console command can be used instead of del.

Del Command Examples

del c:\windows\twain_32.dll

In the above example, the del command is used to delete the twain_32.dll file located in the C:\Windows folder.

del io.sys

In this example, the del command has no path information specified, so the io.sys file is deleted from whatever directory you typed the del command from.

For example, if you type del io.sys from the C:\> prompt, the io.sys file will be deleted from C:\.

del C:\Users\Tim\Downloads\*.exe

This del command will remove all EXE files from the Tim user's Downloads folder. The file extension could be replaced with * to delete every file from that folder.

Important: Notice that 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.

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.

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.

del /s C:\Users\Tim\Documents\Adobe\*.*

This del command example will delete every file (*.*) from every folder (/s) inside of 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 command.

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