CMD tree command limit number of levels CMD tree command limit number of levels windows windows

CMD tree command limit number of levels


Since I didn't found complete answer here. Here it is:

Windows CMD doesn't support -L depth levels.

  1. Install CygWin https://www.cygwin.com.
  2. In Cygwin make sure you pick Utilities / Tree package installed.
  3. Open CygWin and navigate to your folder, like cd ../../cygdrive/c/myFolder.
  4. List tree structure and save as result.txt tree -L 3 >result.txt.


Actually, the tree command in DOS and Windows does not have the option for specifying the directory level that the command goes through. You can refer to the documentation of tree on Microsoft Docs.

But you can use Git Bash instead. This tool is provided when you install Git for Windows. So in this way, you can use the command that @Zhengquan Feng mentioned.


  1. Try to download WSL in your Windows system.

  2. In your command prompt:

    bash

  3. Then you can use Linux commands:

    tree -L x(the layer)