Del, Erase - DOS/Command Prompt Reference
Deletes the file. Can delete multiple files by using wildcards.
del <file-name> [/P] [/F] [/S] [/Q] [/A[[:]<attribute>]]
erase <file-name> [/P] [/F] [/S] [/Q] [/A[[:]<attribute>]]
|del, erase||This command can be either ‘del’ or ‘erase’.|
Specifies the file name to delete. By using wildcards multiple files can be deleted. The directory itself can be specified; in the case all files in the directory will be deleted.
If specifying the directory or ‘*.*’, the command confirms the deletion with a message ‘Are you sure?’. ([Windows NT series/XP or later] This confirmation can be skipped by /Q option.)
[Windows NT series/XP or later] You can specify multiple files by separating with spaces.
|/P||Prompts the confirmation before file deletion. The prompt will be displayed for each files.|
|/F||[Windows NT series/XP or later] Forces deleting the file even if the file has read-only attribute.|
|/S||[Windows NT series/XP or later] If the target is a directory, and its directory has subdirectories, deletes all files in its directory and the subdirectories.|
|/Q||[Windows NT series/XP or later] Suppresses the confirmation of file deletion when specifying the directory, using wildcard ‘*.*’, or using /S option. (Does not negate the effect of /P.)|
[Windows NT series/XP or later] Filters the target files by attributes. If omitting <attribute> (using ‘/A’ only), hidden files and system-file attribute files will be included.
<attribute> will be the attribute characters to filter. The attribute characters are R, A, S, H, and use one or more of these chracters (R = Read-only file, A = Archive (ready for archiving), S = System file, H = Hidden file). ‘-’ prefix means ‘not’ (i.e. ‘files other than its attribute’).
By default read-only attribute files are included, but ‘Access denied’ occurs on deletion of these files, so you need to specify /F option, or specify R to /A <attribute> (to delete read-only files only).
<attribute> can be multiple attribute characters such as ‘SH’. In this case, target files are filtered to match all attributes.
[Windows Vista? or later] I L O characters can also be specified to <attribute> (I = Not content indexed file, L = Reparse point (e.g. symbolic links or junction points), O = Offline file).
This command deletes specified files. Unlike Windows delete operation, the files are not moved to the Recycle Bin, so ([MS-DOS] ‘Undelete’ program provides the feature like the Recycle Bin).
When specifying the directory name to the parameter, Del deletes all files in the directory, but (even if specifying /S option) the directory itself will not be deleted. To delete the directory, use Rmdir or Deltree ([MS-DOS, Windows 95/98/Me only]).
Deletes the file ‘test’. If ‘test’ is an existing directory, deletes all files in ‘test’ directory. (In this case ‘test’ itself and the subdirectories inside will remain.)
Deletes all files with its name ‘test’ and any extension. However ‘test’ directory is excluded.
Please see also ‘|’ sample for deleting all files.