Deletes a directory and all the subdirectories and files in it.


To delete a directory and all the subdirectories and files contained therein:
DELTREE [/Y] directory

To delete all the files and subdirectories but leave the directory itself:
DELTREE [/Y] directory\*.*

To delete a file:
DELTREE [/Y] filename

directoryThe directory to be deleted.
/YSuppresses prompts for confirmation before deleting.


The DELTREE command deletes all files contained in a directory or subdirectory, regardless of whether files are marked as hidden, system, or read-only.

Unlike the typical syntax order for most Dos commands, if the /Y switch is used, it must precede the directory parameters.

The DELTREE command supports wildcards, but they should be used with some 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 /A command to view the files and directories you will delete. It is also safest to specify the full path to avoid any surprises from ambiguous specification.

Only the files in the top directory deleted with DELTREE can be recovered using UNDELETE. Files in subdirectories are lost forever - as far as Dos is concerned, anyway.


To delete the TEMP directory on drive C, including all files and subdirectories of the TEMP directory:
DELTREE c:\temp

To delete all the files and subdirectories in the "temp" directory leaving an empty "temp" directory for future use, and avoiding the prompt for confirmation:
DELTREE /Y c:\temp\*.*

To delete the read-only file text.doc in the c:\data directory (without resetting the attributes):
DELTREE /Y c:\data\text.doc

Exit Codes:

0It would appear that Deltree returns this code whatever happens.

File Details

File NameDefault LocationDos Ver.Win Ver.SizeDateSource
Deltree.exec:\windows\command 7.0Win95 19 019111/07/
7.1Win95 (OSR2.x) 19 019124/08/
Win98 19 083211/05/
Win98 SE 19 083223/04/

Superscripts denote which same size files, if any, are identical (using FC).

If you should have any comments or suggestions,
please contact: Bob Watson
This page last revised:
August 27, 2000.