Maximum number of CMD tree commands

How to limit the number of levels that the tree command executes on Windows? I need to output the results to a text file for work, but since by default the tree command lists each directory under the one in which you ran the command, the output I get is more than 44,000 lines, which does not help at all for my work. How to limit it to listing only the first levels of a pair?

+4
source share
3 answers

Actually, the DOS tree command does not have a level option. You can refer to the manual: the tree in the windows .

But you can use git bash (this is the tool provided by git when installing git on windows) or babun (this is a really good tool for a Windows user to use * unix tools), so you can use the command mentioned by @Zhengquan Feng.

+5
source

Since I did not find a complete answer here. Here he is:

Windows CMD does not support -L depth levels.

  • Install CygWin https://www.cygwin.com .
  • In Cygwin, make sure you select the Utilities / Tree package.
  • Open CygWin and browse to your folder, for example, cd ../../cygdrive/c/myFolder .
  • Write off the tree structure and save as result.txt tree -L -3 >result.txt .
0
source

You can try this project on Windows:

https://github.com/MrRaindrop/tree-cli

Using:

use -l levelNumber to indicate the level of the path:

treee -l 2

0
source

All Articles