The Windows tree
command does unfortunately not support an option for the maximum depth. However, you could filder the output by the findstr
command in the following way:
tree "C:\Test\Game1" /A | findstr /V /B /R /C:"[| ] "
Assuming that the output of this tree
command is something like (using ASCII characters (/A
) rather than extended ones, because they are easier to handle as they do not depend on the current code page):
Folder PATH listing for volume &&&&
Volume serial number is ####-####
C:\TEST\GAME1
+---folder1
| +---folder11
| | +---folder111
| | \---folder112
| \---folder12
| +---folder111
| \---folder112
+---folder2
| +---folder21
| \---folder22
\---folder3
+---folder31
\---folder32
The findstr
command removes (/V
) everything that begins (/B
) with |
or SPACE and is followed by three more SPACEs. These criteria are fulfilled for all lines that show a folder that is deeper then level 1. Hence the output would be something like this:
Folder PATH listing for volume &&&&
Volume serial number is ####-####
C:\TEST\GAME1
+---folder1
+---folder2
\---folder3
To display more levels, simply extend the search expression accordingly; so to go down until level 2, use /C:"[| ] [| ] "
.
To hide the header (containing the volume information and the upper-case root path), just append a SPACE and /C:"[^+|\\]"
to the command line.
Note that the Windows path separator is \
but not /
.