Del (or Erase)

Index

Deletes named files. DEL and ERASE are synonymous.

Syntax:

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 \**

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

Notes:

  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"
    
    D:\>_
     

  2. DEL will not delete files that have "read-only", "hidden", and/or "system" attributes set. To delete such files, it is necessary to use DELTREE or to 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:

File Details:

Internal


If you should have any comments or suggestions,
please contact: Bob Watson
.
This page last revised:
December 9, 1999.