DEL - Delete one or more files
Purpose: Erase one file, a group of files, or entire subdirectories.
Format: DEL [/A:[[-]rhsda] /E /F /N /P /Q /S /T /W /X /Y /Z] file ...
or
ERASE [/A:[[-]rhsda] /E /F /N /P /Q /S /T /W /X /Y /Z] file
...
file : The file, subdirectory, or list of files or
subdirectories to erase.
/A: (ttribute select) /S(ubdirectories)
/E (no Error messages) /T(otal)
/F(orce delete) /W(ipe)
/N(othing) /X (remove empty
subdirectories)
/P(rompt) /Y(es to all prompts)
/Q(uiet) /Z(ap hidden and read-only
files)
File Selection
Supports extended wildcards, ranges, multiple file names, and include
lists.
Usage
DEL and ERASE are synonyms, you can use either one.
Use the DEL and ERASE commands with caution; the files and subdirectories
that you erase may be impossible to recover without specialized utilities
and a lot of work.
To erase a single file, simply enter the file name:
[c:\] del letters.txt
You can also erase multiple files in a single command. For example, to
erase all the files in the current directory with a .BAK or .PRN
extension:
[c:\] del *.bak *.prn
When you use DEL on an HPFS drive, you must quote any file names which
contain whitespace or special characters. See File Names for additional
details.
To exclude files from a DEL command, use a file exclusion range. For
example, to delete all files in the current directory except those whose
extension is .TXT, use a command like this:
[c:\] del /[!*.TXT] *.*
When using exclusion ranges or other more complex options you may want to
use the /N switch first, to preview the effects of the DEL without
actually deleting any files.
If you enter a subdirectory name, or a filename composed only of
wildcards (* and/or ?), DEL asks for confirmation (Y or N) unless you
specified the /Y option. If you respond with a Y, DEL will delete all
the files in that subdirectory (hidden, system, and read-only files are
only deleted if you use the /Z option).
DEL displays the amount of disk space recovered, unless the /Q option is
used (see below). It does so by comparing the amount of free disk space
before and after the DEL command is executed. This amount may be
incorrect if you are using a deletion tracking system which stores
deleted files in a hidden directory, or if, under a multitasking system,
another program performs a file operation while the DEL command is
executing.
Remember that DEL removes file descriptions along with files. Most
deletion tracking systems will not be able to save or recover a file's
description, even if they can save or recover the data in a file.
When a file is deleted, its disk space is returned to the operating
system for use by other files. However, the contents of the file remain
on the disk until they are overwritten by another file. If you wish to
obliterate a file or wipe its contents clean, use DEL /W, which
overwrites the file with zeros before deleting it. Use this option with
caution -- once a file is obliterated, it is impossible to recover.
DEL returns a non-zero exit code if no files are deleted, or if another
error occurs. You can test this exit code with the %_? environment
variable, and use it with the conditional commands && and ||).
Options
/A:: (Attribute select) Select only those files that have the
specified attribute(s) set. Preceding the attribute character
with a hyphen [-] will select files that do not have that
attribute set. The colon [:] after /A is required. The
attributes are:
R Read-only
H Hidden
S System
D Subdirectory
A Archive
If no attributes are listed at all (e.g., DEL /A: ...), DEL will select
all files and subdirectories including hidden and system files. If
attributes are combined, all the specified attributes must match for a
file to be selected. For example, /A:RHS will select only those files
with all three attributes set. /E:(No error messages) Suppress all
non-fatal error messages, such as "File Not Found." Fatal error
messages, such as "Drive not ready," will still be displayed. This
option is most useful in batch files and aliases. /F:(Force delete) This
option forces deletion of the file without saving it to the DELDIR
directory (if DELDIR is not in use, /F has no effect). /N:(Nothing) Do
everything except actually delete the file(s). This is useful for
testing what the result of a DEL would be. /P:(Prompt) Prompt the user to
confirm each erasure. Your options at the prompt are explained in detail
under Page and File Prompts. /Q:(Quiet) Don't display filenames as they
are deleted, or the number of files deleted or bytes freed. See also /T.
/S:(Subdirectories) Delete the specified files in this directory and all
of its subdirectories. This can be used to delete all the files in a
subdirectory tree or even a whole disk. It should be used with caution!
/T:(Total) Don't display filenames as they are deleted, but display the
total number of files deleted plus the amount of free disk space
recovered. Unlike /Q, the /T option will not speed up deletions under
DOS. /W:(Wipe) Clear the file to zeros before deleting it. Use this
option to completely obliterate a file's contents from your disk. Once
you have used this option it is impossible to recover the file even if
you are using an undelete utility, because the contents of the file are
destroyed before it is deleted. /W overwrites the file only once; it
does not adhere to security standards which require multiple overwrites
with varying data when destroying sensitive information. /X:(Remove empty
subdirectories) Remove empty subdirectories after deleting (only useful
when used with /S). If DEL deletes one or more directories, they will be
removed automatically from the extended directory search database.
/Y:(Yes) The reverse of /P -- it assumes a Y response to everything,
including deleting an entire subdirectory tree. CMD.EXE normally prompts
before deleting files when the name consists only of wildcards or a
subdirectory name (see above); /Y overrides this protection, and should
be used with extreme caution! /Z:(Zap) Delete read-only, hidden, and
system files as well as normal files. Files with the read-only, hidden,
or system attribute set are normally protected from deletion; /Z
overrides this protection, and should be used with caution. Because
EXCEPT works by hiding files, /Z will override an EXCEPT command.
However, files specified in a file exclusion range will not be deleted
by DEL /Z.
For example, to delete the entire subdirectory tree starting with
C:\UTIL, including hidden and read-only files, without prompting (use
this command with CAUTION!):
[c:\] del /sxyz c:\util\
Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs