In Windows, How to display a Tree view of files or folders in a project? The folder tree view displays all the files and directories with a nested tree view.

In Linux OS, It is easy to print a directory tree view of a folder.

Windows to view files and folder tree view

tree command list out all files and folders in a directory.

syntax

tree [sourcedirectory] [options]

sourcedirectory: Optional, can give the name of the folder Options are -F or /A, both are optional.

  • /F option list out every file in a nested directory
  • /A removing graphic characters and using ASCII format for viewing in a text editor such as note pad.

Here is an output tree command

tree command

A:.
└───node_modules
    ├───.bin
    └───prettier
        └───esm

tree command with -f option

A:\work\w3schools\json>tree  /f
Folder PATH listing for volume Work
Volume serial number is C682-8F53
A:.
│   employee.json
│   output.json
│   package-lock.json
│   package.json
│   prettyprint-node.js
│   read-json.js
│   read.html
│   user.json
│   write-json.js
│
└───node_modules
    │   .package-lock.json
    │
    ├───.bin
    │       prettier
    │       prettier.cmd
    │       prettier.ps1
    │
    └───prettier
        │   bin-prettier.js
        │   doc.js
        │   index.js
        │   LICENSE
        │   package.json
        │   parser-angular.js
        │   parser-babel.js
        │   parser-espree.js
        │   parser-flow.js
        │   parser-glimmer.js
        │   parser-graphql.js
        │   parser-html.js
        │   parser-markdown.js
        │   parser-meriyah.js
        │   parser-postcss.js
        │   parser-typescript.js
        │   parser-yaml.js
        │   README.md
        │   standalone.js
        │   third-party.js
        │
        └───esm
                parser-angular.mjs
                parser-babel.mjs
                parser-espree.mjs
                parser-flow.mjs
                parser-glimmer.mjs
                parser-graphql.mjs
                parser-html.mjs
                parser-markdown.mjs
                parser-meriyah.mjs
                parser-postcss.mjs
                parser-typescript.mjs
                parser-yaml.mjs
                standalone.mjs

tree command with -a option

It sends an output to text file using pipe in dos

tree  /f /a > output.txt

output.tx content:

Folder PATH listing for volume Work
Volume serial number is C682-8F53
A:.
|   employee.json
|   output.json
|   output.tx
|   output.txt
|   package-lock.json
|   package.json
|   prettyprint-node.js
|   read-json.js
|   read.html
|   user.json
|   write-json.js
|   
\---node_modules
    |   .package-lock.json
    |   
    +---.bin
    |       prettier
    |       prettier.cmd
    |       prettier.ps1
    |       
    \---prettier
        |   bin-prettier.js
        |   doc.js
        |   index.js
        |   LICENSE
        |   package.json
        |   parser-angular.js
        |   parser-babel.js
        |   parser-espree.js
        |   parser-flow.js
        |   parser-glimmer.js
        |   parser-graphql.js
        |   parser-html.js
        |   parser-markdown.js
        |   parser-meriyah.js
        |   parser-postcss.js
        |   parser-typescript.js
        |   parser-yaml.js
        |   README.md
        |   standalone.js
        |   third-party.js
        |   
        \---esm
                parser-angular.mjs
                parser-babel.mjs
                parser-espree.mjs
                parser-flow.mjs
                parser-glimmer.mjs
                parser-graphql.mjs
                parser-html.mjs
                parser-markdown.mjs
                parser-meriyah.mjs
                parser-postcss.mjs
                parser-typescript.mjs
                parser-yaml.mjs
                standalone.mjs