Purpose:Display a graphical directory tree


Format:TREE [/\ /A:[-|+]rhsadecijopt /A /B /D /F /H /L /Nj /O:[-]acdeginorstuz /P[n] /S[n] /T[:a|c|w] /Z ] dir...


dirThe directory to use as the start of the tree. If one or more directories are specified, TREE will display a tree for each specified directory. If none are specified, the tree for the current working directory is displayed.


/A: (Attribute select)

/L (colorize display)






/S (file size)


/Sn (subdirectory depth)

/H(idden directories)

/T(ime and date)

/N (disable option)

/Z (file size)


File Selection:


Supports attribute switches, extended wildcards, ranges (with /F), and multiple file names.




The TREE command displays a graphical representation of the directory tree using standard or extended ASCII characters. For example, to display the directory structure on drive C:


[c:\] tree c:\


TREE uses the standard line drawing characters in the U.S. English extended ASCII character set. If your system is configured for a different country or language, or if you use a font which does not include these line drawing characters, the connecting lines in the tree display may not appear correctly (or not appear at all) on your screen. To correct the problem, use /A, or configure TCC-RT to use a font which can display standard extended ASCII characters.


You can print the display, save it in a file, or view it with LIST by using standard redirection symbols. Be sure to review the /A option before attempting to print the TREE output. The options discussed below specify the amount of information included in the display.




TREE can display each file name and the associated file information in a different color, depending on the file's extension, attributes, or matching range.


To choose the display colors, you must either use the SET command to create an environment variable called COLORDIR, or use the Directory Colors configuration option. If you use neither the variable nor the configuration option, DIR will use the default screen colors for all files.


If you use the COLORDIR variable, it will override the Directory Colors option. You may find it useful to use the COLORDIR variable for experimenting, then to set permanent directory colors with the Directory Colors option.


The format for both the COLORDIR environment variable and the Directory Colors option is:


ext ... :ColorName; ...


where "ext" is either a file extension (which may include wildcards), one or more of the following file types:



files affected


Files with archive attribute set (modified since the last backup)


Compressed files




Encrypted files


Hidden files


Junctions or symbolic links


File with no attribute set


Files whose content is not indexed


Offline files


Read-only files


Sparse files


System files


temporary files


or a range (size, date, time, description, owner, and/or exclusion), or a file subsystem type:


EXETYPE_WIN32GUIWindows x86 GUI app
EXETYPE_WIN32CUIWindows x86 console app
EXETYPE_WIN64GUIWindows x64 GUI app
EXETYPE_WIN64CUIWindows x64 console app
EXETYPE_DOSDOS (16-bit) app (obsolete)


and "ColorName" is any valid color name (see Colors and Color Names for information on color names). Specifying a subsystem type will significantly slow down the directory display, as TCC-RT has to read the header of each file to find a match.


Note that if a file uses one of the reserved file type names shown above as its extension (e.g. xyz.hidden) , that file will receive the color defined for the file type.


Unlike most color specifications, the background portion of the color name may be omitted for directory colors. If you don't specify a background color, DIR will use the current screen background color.


For example, to display .COM and .EXE files in red on the current background, .C and .ASM files in bright cyan on the current background, read-only files in green on white, and everything else in the default color:


set colordir=exe:red; c asm:bright cyan; rdonly:green on white


To display 32-bit console apps in bright green and 64-bit console apps in bright red:


set colordir=EXETYPE_WIN32CUI:bri green;EXETYPE_WIN64CUI:bri red


Extended wildcards can be used in directory color specifications. For example, to display .BAK, .BAX, and .BAC files in red, and everything else in the default color:


set colordir=BA[KXC]:red


You can combine attribute tests with the .and. / .or. / .xor. / .not. keywords. For example, to display directories that are also hidden in blue:


set colordir=dirs .and. hidden:blue


COLORDIR processes the line from left to right, and does not support parentheses.




/\Display directory names with a trailing \.


/ADisplay the tree using standard ASCII characters. You can use this option if you want to save the directory tree in a file for further processing or print the tree on a printer which does not support the graphical symbols that TREE normally uses.


/A:[..]Select only those files that match the specified attribute(s).See Attribute Switches for details.


You can specify /A:= to display a dialog to help you set individual attributes.


/BDisplay the full pathname of each directory, without any of the line-drawing characters.


/DDisplay file and directory descriptions.


/FDisplay files as well as directories. If you use this option, the name of each file is displayed beneath the name of the directory in which it resides.


/HDisplay hidden as well as normal directories. If you combine /H and /F, hidden files are also displayed.


/LColorize the display. See Colors (above) for details.


/NDisables the specified options:


jSkip junctions


/O:...Sort the files before processing. You may use any combination of the sorting options below. If multiple options are used, the listing will be sorted with the first sort option as the primary key, the next as the secondary key, and so on:


nSort by filename and extension, unless e is explicitly included. This is the default.
-Reverse the sort order for the next sort key
aSort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension.
cSort by compression ratio
dSort by date and time (oldest first); also see /T:acw
eSort by extension
gGroup subdirectories first, then files
iSort by description
oSort by owner
rReverse the sort order for all options
sSort by size
tSame as d
zSame as s


/P[n]Wait for a key to be pressed after each screen page before continuing the display. Your options at the prompt are explained in detail under Page and File Prompts. The /P option has an optional argument n that specifies the number of seconds to wait for a keystroke before continuing.


/SIf you specify a number after the /S, TREE will limit the subdirectory recursion to that number. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only affect the "a", "b", and "c" directories. If you do not specify a number, /S shows the file sizes (see /Z).


/TDisplay the time and date for each directory. If you combine /T and /F, the time and date for each file will also be displayed.


By default, the time and date shown will be of the last modification. You can select a specific time and date stamp by using the following variations of /T:


/T:a        Last access date and time (access time is not displayed on VFAT and FAT32 volumes).

/T:c        Creation date and time.

/T:w        Last modification ("write") date and time (default).


/ZDisplay the size of each file. /Z without a /F will display the subdirectory tree sizes (the size of the current directory and all of its subdirectories).