FileSystemTree[root]
gives a tree whose keys are the names of files in root, and whose data is the full names of these files.
FileSystemTree[root,levelspec]
gives a tree in which files on levels specified by levelspec are represented by a subtree.
FileSystemTree[root,levelspec,r]
combines levels to give a tree with maximum level r.
FileSystemTree
FileSystemTree[root]
gives a tree whose keys are the names of files in root, and whose data is the full names of these files.
FileSystemTree[root,levelspec]
gives a tree in which files on levels specified by levelspec are represented by a subtree.
FileSystemTree[root,levelspec,r]
combines levels to give a tree with maximum level r.
Details and Options
- FileSystemTree uses standard level specifications as in TreeLevel:
-
n levels 1 through n All levels 0 through Infinity Infinity levels 1 through Infinity {n} level n only {n1,n2} levels n1 through n2 - The default value for levelspec in FileSystemTree is {0,Infinity}.
- FileSystemTree has the same options as Tree, with the following additions:
-
IncludeDirectories False whether to include All as a leaf of each directory FileNameForms All include files with names of the specified forms MaxItems Infinity maximum items to include from a directory - FileNameForms will accept any forms specification allowed in the first argument of FileNames.
Examples
open all close allBasic Examples (3)
Create a tree of all files contained in a directory:
FileSystemTree[$InstallationDirectory]Create a tree of all files through level 2 of the specified directory:
FileSystemTree[$UserBaseDirectory, 2]Create a tree containing only those files at level 2 of the specified directory:
FileSystemTree[$InstallationDirectory, {2}]Create a flat tree for the same directory:
FileSystemTree[$InstallationDirectory, {2}, 1]Options (12)
Elision (1)
FileNameForms (1)
By default, all files are included:
FileSystemTree[FileNameJoin[{$InstallationDirectory, "/Documentation/English/System/ExampleData"}]]By specifying FileNameForms->patt, the tree will be restricted to only those files that match the specified pattern:
FileSystemTree[FileNameJoin[{$InstallationDirectory, "/Documentation/English/System/ExampleData"}], FileNameForms -> "*.pdb"]IncludeDirectories (1)
Empty directories have no children by default:
FileSystemTree[$UserBaseDirectory, 2]Include All as a child of every directory:
FileSystemTree[$UserBaseDirectory, 2, IncludeDirectories -> True]MaxItems (1)
By default, the tree will contain all files in the specified directory and subdirectories:
FileSystemTree[FileNameJoin[{$InstallationDirectory, "SystemFiles", "CharacterEncodings"}]]By specifying MaxItemsn, the tree will contain at most n items within each directory:
FileSystemTree[FileNameJoin[{$InstallationDirectory, "SystemFiles", "CharacterEncodings"}], MaxItems -> 2]Styling Entire Tree (4)
Specify labels and styles for all subtrees:
FileSystemTree[$InstallationDirectory, 3, ParentEdgeLabelFunction -> All -> None, TreeElementStyle -> All -> EdgeForm[Red]]FileSystemTree[$InstallationDirectory, 3, BaseStyle -> LightRed]Specify the style for the edges and the edges of the tree elements:
FileSystemTree[$InstallationDirectory, 3, BaseStyle -> {Dashed, EdgeForm[{Dashing[{}], Thick}]}]Specify the base style and styles for individual tree elements:
FileSystemTree[$InstallationDirectory, 1, BaseStyle -> {Red, EdgeForm[None]}, TreeElementStyle -> All -> Opacity[0], ParentEdgeLabel -> All -> None]Styling Individual Tree Elements (1)
Tree Layout and Graphics Options (3)
Specify the orientation for the root:
FileSystemTree[$InstallationDirectory, 2, TreeLayout -> Left]FileSystemTree[$InstallationDirectory, 3, TreeLayout -> "BalloonEmbedding"]Specify Graphics options:
FileSystemTree[$InstallationDirectory, 1, Background -> LightBlue, ImageSize -> Full]Properties & Relations (1)
TreeExpression[FileSystemTree[root,…],"FileSystem"] is equivalent to FileSystemMap[Identity,root,…]:
FileSystemTree[$InstallationDirectory, 2]TreeExpression[%, "FileSystem"]% === FileSystemMap[Identity, $InstallationDirectory, 2]Related Guides
History
Text
Wolfram Research (2022), FileSystemTree, Wolfram Language function, https://reference.wolfram.com/language/ref/FileSystemTree.html.
CMS
Wolfram Language. 2022. "FileSystemTree." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FileSystemTree.html.
APA
Wolfram Language. (2022). FileSystemTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileSystemTree.html
BibTeX
@misc{reference.wolfram_2026_filesystemtree, author="Wolfram Research", title="{FileSystemTree}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/FileSystemTree.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_filesystemtree, organization={Wolfram Research}, title={FileSystemTree}, year={2022}, url={https://reference.wolfram.com/language/ref/FileSystemTree.html}, note=[Accessed: 15-June-2026]}