Deletes a directory and all the files and subdirectories that are in it.
DELTREE [/Y] [drive:]path [[drive:]path[...]]
For information about removing a directory, see the
RMDIR command.
For information about deleting files, see the
DEL command.
The DELTREE command deletes all files contained in a directory or subdirectory, regardless of attributes.
You can use wildcards with the DELTREE command, but use them with extreme caution. If you specify a wildcard that matches both directory names and filenames, both the directories and files will be deleted. Before specifying wildcards with the DELTREE command, use the DIR command to view the files and directories you will delete.
If you specify the trailing slash with the directory name, the directory will be left empty. If you don't specify the trailing slash, the directory will also be deleted.
To delete the TEMP directory on drive C, including all files and subdirectories of the TEMP directory, type:
DELTREE C:]\TEMP (MSDOS6.22) (WIN98)
Deletion in a directory
To delete all files and subdirectories of the TEMP directory on drive C, type:
DELTREE C:]\TEMP\ (MSDOS6.22) (WIN98) DELTREE C:]\TEMP\. (MSDOS6.22) (WIN98) DELTREE C:]\TEMP\*.* (MSDOS6.22) (WIN98) DELTREE C:]\TEMP\* (WIN98)
To delete (from TEMP directory on drive C) all those files and subdirectories that do have an extension TMP, type:
DELTREE C:]\TEMP\*.TMP (MSDOS6.22) (WIN98)
To delete (from TEMP directory on drive C) only those files and subdirectories that don't have an extension, type:
DELTREE C:]\TEMP\*. (MSDOS6.22) (WIN98) DELTREE C:]\TEMP\* (MSDOS6.22)
Notes: If you always give your filenames an extension but never give your subdirectory names an extension (which is the usual practice), then the above syntax can be used to delete ONLY subdirectories of TEMP but leave normal files.
All content AND named directory as well:
DELTREE /Y C:]\TEMP > nul
All content but NOT the named directory:
DELTREE /Y C:]\TEMP\ > nul
Subdirectories of named directory (without .EXTension):
DELTREE /Y C:]\TEMP\*. > nul
All names whose extension are exact TMP:
DELTREE /Y C:]\TEMP\*.TMP > nul