{"id":31626417,"url":"https://github.com/wisedodge/dirmap-script","last_synced_at":"2026-04-20T06:02:41.494Z","repository":{"id":315153753,"uuid":"1039446132","full_name":"WiseDodge/DirMap-Script","owner":"WiseDodge","description":"A simple PowerShell script to generate a visual directory tree of any folder.","archived":false,"fork":false,"pushed_at":"2025-09-17T00:22:25.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-06T19:53:01.011Z","etag":null,"topics":["automation","batch-script","cli","command-line-tool","directory-listing","directory-map","directory-tree","file-system","folder-structure","powershell","powershell-script","script","utility","windows"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WiseDodge.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-17T08:45:14.000Z","updated_at":"2025-09-17T00:29:44.000Z","dependencies_parsed_at":"2025-09-17T02:32:31.020Z","dependency_job_id":"bb2afd18-d74c-47c8-9ad4-7f26316ff2ef","html_url":"https://github.com/WiseDodge/DirMap-Script","commit_stats":null,"previous_names":["wisedodge/dirmap-script"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WiseDodge/DirMap-Script","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WiseDodge%2FDirMap-Script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WiseDodge%2FDirMap-Script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WiseDodge%2FDirMap-Script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WiseDodge%2FDirMap-Script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WiseDodge","download_url":"https://codeload.github.com/WiseDodge/DirMap-Script/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WiseDodge%2FDirMap-Script/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32035276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","batch-script","cli","command-line-tool","directory-listing","directory-map","directory-tree","file-system","folder-structure","powershell","powershell-script","script","utility","windows"],"created_at":"2025-10-06T19:51:58.413Z","updated_at":"2026-04-20T06:02:41.489Z","avatar_url":"https://github.com/WiseDodge.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DirMap Script 📁\n![GitHub last commit](https://img.shields.io/github/last-commit/WiseDodge/DirMap-Script)\n\n**A PowerShell script to generate a visual directory tree of any folder.**\n\n\u003e This tool creates a text file that **shows a map of all your folders**. I made it as a folder-only successor to `tree /f \u003e directoryinROOT.txt`, which is one of my most-used Windows commands. It has two versions: one you run from a Powershell window, and one you just double-click. Both files will save the output in the same directory as the provided path.\n\n-----\n\n## 🚀 Features\n\n  * 🗂️ **Folder-Only Output** — Unlike the standard `tree` command, this script only maps folders, making the output cleaner and easier to read.\n  * 📄 **Text File Export** — Creates a `directoryinROOT.txt` file in the specified directory, which is easy to share via email, chat, and other platforms.\n  * 💻 **Dual Usage Methods** — Supports two methods of operation: a PowerShell file for command-line use, and a batch file for simple double-click execution.\n\n-----\n\n## 📂 How It Works\n\nThe script simply prompts the user for a directory path, and then proceeds to recursively scan that directory to generate a visual tree structure of all the folders within. It then saves this map into a text file named `directoryinROOT.txt` in that same root folder.\n\n-----\n\n## 📸 Sample Output\n\nThe output will look similar to this:\n\n```\nC:\\Users\\Username\\Documents\\\n├───Project Alpha\n│   ├───Documents\n│   └───Source\n├───Project Beta\n│   ├───Assets\n│   │   ├───Images\n│   │   └───Models\n│   └───Scripts\n└───Vacation Photos\n    ├───2023\n    └───2024\n```\n\n-----\n\n## 🧰 Usage\n\n### Method 1: The PowerShell File (`.ps1`)\n\n*Use this if you prefer running scripts from the PowerShell window.*\n\n1.  Navigate to the `src/` directory in PowerShell.\n\n2.  Run the script with the following command:\n\n    ```powershell\n    .\\Get-FolderTree.ps1\n    ```\n\n3.  The script will prompt you to enter the path of the directory you want to map. \n    \u003e *Tip: You can get a directory's path by clicking on a folder and pressing `Ctrl + Shift + C`.*\n\n\n```ps1\n# Get-FolderTree.ps1\n# This script prompts the user to select a root directory and generates a text file\n# containing a visual tree structure of all folders within that directory.\n\n# Make sure the console output uses the correct character encoding for tree characters\nchcp 65001 \u003e$null\n\n# Define a recursive function to build the directory tree structure\nfunction Get-DirectoryTree {\n    param (\n        [string]$Path,\n        [int]$Level = 0,\n        [string[]]$IndentationPrefixes = @()\n    )\n\n    # Get the items in the current directory, including hidden ones, but only folders\n    $items = Get-ChildItem -Path $Path -Directory -Force | Sort-Object Name\n\n    # Get the number of items to correctly determine last child\n    $count = $items.Count\n    $i = 0\n\n    # Loop through each folder\n    foreach ($item in $items) {\n        $i++\n        $isLastItem = ($i -eq $count)\n\n        # Build the current line's prefix for the tree\n        if ($isLastItem) {\n            $prefix = \"└───\"\n        } else {\n            $prefix = \"├───\"\n        }\n\n        # Build the full indentation string based on the parent levels\n        $indentation = ($IndentationPrefixes -join \"\") + $prefix\n\n        # Print the current folder path with indentation to the pipeline\n        Write-Output \"$indentation$($item.Name)\"\n\n        # Prepare indentation for the next level\n        $newPrefixes = @($IndentationPrefixes)\n        if ($isLastItem) {\n            $newPrefixes += \"    \"\n        } else {\n            $newPrefixes += \"│   \"\n        }\n\n        # Recursively call the function for subdirectories\n        Get-DirectoryTree -Path $item.FullName -Level ($Level + 1) -IndentationPrefixes $newPrefixes\n    }\n}\n\n# Prompt the user for a root directory and validate the input\ndo {\n    $rootPath = Read-Host -Prompt \"Please enter the full path of the directory you want to scan (e.g., C:\\Users\\Username\\Documents)\"\n    if (-not (Test-Path -Path $rootPath -PathType Container)) {\n        Write-Host \"Error: The path '$rootPath' is not a valid directory. Please try again.\" -ForegroundColor Red\n    }\n} while (-not (Test-Path -Path $rootPath -PathType Container))\n\n# Set the file encoding for all outputs in this session\n$PSDefaultParameterValues['Out-File:Encoding'] = 'UTF8'\n\n# Clear the output file before writing to it\nSet-Content -Path \"directoryinROOT.txt\" -Value \"\" -Encoding UTF8\n\n# Write the root path and then the directory tree to the output file\nWrite-Output \"$rootPath\\\" | Out-File -FilePath \"directoryinROOT.txt\" -Encoding UTF8\nGet-DirectoryTree -Path $rootPath | Out-File -FilePath \"directoryinROOT.txt\" -Append -Encoding UTF8\n\nWrite-Host \"Scan complete. The directory tree has been saved to directoryinROOT.txt\" -ForegroundColor Green\n```\n\n### Method 2: The Batch File (`.bat`)\n\n*This version is the easiest to use. It's a single file that runs everything for you with a double-click.*\n\n1.  Navigate to the `src/` directory in Windows Explorer.\n2.  Double-click the batch file (`.bat`) to run it.\n3.  A command window will open, prompting you to enter the directory path.\n\n\n```powershell\n@echo off\nchcp 65001 \u003enul\npowershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"\u0026 {$PSDefaultParameterValues['Out-File:Encoding'] = 'UTF8'; function Get-DirectoryTree {param ([string]$Path, [int]$Level = 0, [string[]]$IndentationPrefixes = @()) $items = Get-ChildItem -Path $Path -Directory -Force | Sort-Object Name; $count = $items.Count; $i = 0; foreach ($item in $items) {$i++; $isLastItem = ($i -eq $count); if ($isLastItem) {$prefix = '└───'} else {$prefix = '├───'}; $indentation = ($IndentationPrefixes -join '') + $prefix; Write-Output ($indentation + $item.Name); $newPrefixes = @($IndentationPrefixes); if ($isLastItem) {$newPrefixes += '    '} else {$newPrefixes += '│   '}; Get-DirectoryTree -Path $item.FullName -Level ($Level + 1) -IndentationPrefixes $newPrefixes}}; do {$rootPath = Read-Host -Prompt 'Please enter the full path of the directory you want to scan (e.g., C:\\Users\\Username\\Documents)'; if (-not (Test-Path -Path $rootPath -PathType Container)) {Write-Host ('Error: The path ' + $rootPath + ' is not a valid directory. Please try again.') -ForegroundColor Red}} while (-not (Test-Path -Path $rootPath -PathType Container)); Set-Content -Path 'directoryinROOT.txt' -Value '' -Encoding UTF8; Write-Output ($rootPath + '\\') | Out-File -FilePath 'directoryinROOT.txt' -Encoding UTF8; Get-DirectoryTree -Path $rootPath | Out-File -FilePath 'directoryinROOT.txt' -Append -Encoding UTF8}\"\npause\n```\n\n-----\n\n## ⚠️ Troubleshooting\n\n**Error:** \"Running scripts is disabled on this system.\"\n\n**Solution:** This is a common security feature. To allow the script to run, open PowerShell as an administrator and enter this command:\n\n```powershell\nSet-ExecutionPolicy RemoteSigned -Scope CurrentUser\n```\n\n-----\n\n## 📜 License\n\nThis project is licensed under the MIT License.\n\n-----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwisedodge%2Fdirmap-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwisedodge%2Fdirmap-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwisedodge%2Fdirmap-script/lists"}