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... |
dir | The 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. |
File Selection:
Supports attribute switches, extended wildcards, ranges (with /F), and multiple file names.
Usage:
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 the TCC 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:
type |
files affected |
ARCHIVE |
Files with archive attribute set (modified since the last backup) |
COMPRESSED |
Compressed files |
DIRS |
Directories |
ENCRYPTED |
Encrypted files |
HIDDEN |
Hidden files |
JUNCTION |
Junctions or symbolic links |
NORMAL |
File with no attribute set |
NOTINDEXED |
Files whose content is not indexed |
OFFLINE |
Offline files |
RDONLY |
Read-only files |
SPARSE |
Sparse files |
SYSTEM |
System files |
TEMPORARY |
temporary files |
or a range (size, date, time, description, owner, and/or exclusion), or a file subsystem type:
EXETYPE_WIN32GUI | Windows x86 GUI app |
EXETYPE_WIN32CUI | Windows x86 console app |
EXETYPE_WIN64GUI | Windows x64 GUI app |
EXETYPE_WIN64CUI | Windows x64 console app |
EXETYPE_DOS | DOS (16-bit) app (obsolete) |
EXETYPE_POSIX | POSIX app (obsolete) |
EXETYPE_EFI | EFI app |
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 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.
Options:
/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.
/F | Display 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. |
/H | Display hidden as well as normal directories. If you combine /H and /F, hidden files are also displayed. |
j | Skip junctions |
n | Sort by filename and extension, unless e is explicitly included. This is the default. |
- | Reverse the sort order for the next sort key |
a | Sort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension. |
c | Sort by compression ratio |
d | Sort by date and time (oldest first); also see /T:acw |
e | Sort by extension |
g | Group subdirectories first, then files |
i | Sort by description |
o | Sort by owner |
r | Reverse the sort order for all options |
s | Sort by size |
t | Same as d |
u | Unsorted |
z | Same 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. |
/S | If 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). |
/T | Display 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).