Del (or Erase)


Deletes named files. DEL and ERASE are synonymous.


To delete a file:
DEL [path] filename [/P]

To delete all files in a directory (with confirmation):
DEL path or
DEL path \*.*

To delete all files in a directory (without confirmation):
DEL path \?*.*
DEL path \** (in Dos7.0 - confirmation is required in Dos7.1)

filenameThe file to delete.
/PForces confirmation before deleting each file.


  1. DEL only accepts one parameter specifying what is to be deleted - though this parameter can be written (using wildcards) so that multiple files are deleted. If more than one parameters is detected, the command aborts and an error message is displayed. DEL will interpreted a long-file-name-with-spaces as multiple parameters, causing an error. Enclosing the long-file-name-with-spaces in inverted commas solves the problem.

    D:\>del test 2.txt
    Too many parameters - 2.txt
    D:\>del "test 2.txt"

  2. DEL will not delete files that have "read-only", "hidden", and/or "system" attributes set. To delete such files, one can use DELTREE or modify the necessary attributes with ATTRIB.

  3. Using either DEL path \*.* or DEL path will delete all files in a directory, but both forms first give a warning that all files in the directory will be deleted and ask for confirmation before proceeding. To avoid this message and the request for confirmation (which can be trying in batch files) there are a number of alternatives:
    • DEL [path] \?*.*
    • DEL [path] \** (in Dos7.0 - confirmation required in Dos7.1)
    • ECHO Y | DEL [path] \*.*
    • DELTREE /Y [path] \*.*

  4. On the other hand, to require confirmation before each file in a group is deleted, use:

  5. There is no easy way to delete a specific file or group of files from all branches of a directory. For this task, a third party "sweep delete" utility is often employed, although it is possible to do the job by constructing a complex batch program of your own, for example: sweepdel.bat.

File Details:


This page last revised:
January 1, 2003.