๐Ÿงพ PSDirectoryTree ๐Ÿ“

PSDirectoryTree is a PowerShell module for visualizing directory structures in a clear, tree-like format. It supports .gitignore filtering, JSON output, progress indication, and optional file export โ€” making it ideal for documentation, automation, or codebase exploration.

โœจ Features


๐Ÿ”ง Installation

Install the module from PowerShell Gallery:

Install-Module PSDirectoryTree -Scope CurrentUser

๐Ÿ“ฆ View on PowerShell Gallery


๐Ÿš€ Usage Examples

Visual tree in the console

Get-DirectoryTree -RootPath "."

Output as JSON

Get-DirectoryTree -RootPath "." -AsJson

Save tree output to a file

Get-DirectoryTree -RootPath "." -OutputFile ".\tree.txt"

Save JSON structure to file

Get-DirectoryTree -RootPath "." -AsJson -OutputFile ".\structure.json"

โš™๏ธ Parameters

Parameter Description
RootPath The root directory to scan.
MaxDepth Maximum depth to traverse (default: 100).
Filter Filter output: All, Folders, or Files.
IgnoreGitIgnore Skip .gitignore filtering.
AsJson Output the result as a JSON object.
OutputFile File path to save the output. Works with text or JSON.

๐Ÿ–ผ๏ธ Example Output

project-root
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ index.ts
โ”‚   โ””โ”€โ”€ app.ts
โ”œโ”€โ”€ dist
โ”‚   โ””โ”€โ”€ bundle.js
โ””โ”€โ”€ README.md

๐Ÿ“ GitIgnore Integration


๐Ÿงพ JSON Structure

When -AsJson is used, the output will look like this:

{
  "Name": "project-root",
  "Path": "C:\\Path\\To\\project-root",
  "Type": "Folder",
  "Children": [
    {
      "Name": "index.html",
      "Path": "C:\\Path\\To\\project-root\\index.html",
      "Type": "File",
      "Children": []
    },
    {
      "Name": "src",
      "Path": "C:\\Path\\To\\project-root\\src",
      "Type": "Folder",
      "Children": [
        {
          "Name": "main.ts",
          "Path": "C:\\Path\\To\\project-root\\src\\main.ts",
          "Type": "File",
          "Children": []
        }
      ]
    }
  ]
}

This format is ideal for further processing, such as feeding into frontend tools, documentation systems, or CI reports.


๐ŸŽจ Output Colors

Type Color
Folder Cyan
.ts Blue
.js Yellow
.css Green
.html Magenta
.json Dark Yellow
Other files Gray

โœ… License

This project is licensed under the MIT License.


Maintained by Vikansys AB