Generate an ASCII tree for any directory (like the tree command).
Commands
Directory List: List Directories (Text) Command ID: directoryListPrint.listDirectory
Lists directories in plain text.
Directory List: Export as CSV Command ID: directoryListPrint.exportCSV
Directory List: Export as JSON Command ID: directoryListPrint.exportJSON
Directory List: Create Structure (ASCII Tree) Command ID: directoryListPrint.createStructureFromAscii
Parses an ASCII tree file and creates the folders/files under a chosen root.
Directory List: Create Structure (Line-Based) Command ID: directoryListPrint.createStructureLineBased
Reads a text file with lines ending in / as folders and the rest as files.
Directory List: Generate ASCII Tree Command ID: directoryListPrint.generateAsciiTree
Recursively traverses a folder, displaying it as an ASCII tree.
Usage
Install dependencies: npm install
Compile: npm run compile
Open in VS Code, press F5 to launch an Extension Development Host.
Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and look for commands under Directory List: ....
ASCII Tree Notes
The extension uses a simple indentation-based parser (4 spaces per indent).
If your tree uses different spacing, adjust the code to match your style.
If your lines do not show full subdirectories, you’ll get partial paths. For deeper structure, consider providing the full path or use the advanced parser with consistent indentation.
Example 1: Create Structure from a Line-Based File
The extension strips├, ─, └, │ to derive basic line-based paths.
For nested folders, consider providing full paths or using an advanced parser.
Limitations
ASCII Tree Indentation: The extension’s ASCII tree parser relies on a consistent number of spaces (e.g., 2, 3, or 4) per indentation level. If the diagram uses tabs or inconsistent spacing, the generated directory structure may be incorrect.
No Full Paths: By default, ASCII trees don’t list the full path on each line. The extension infers nesting by indentation. If you need a highly reliable approach, consider providing explicit full paths or a line-based file.
Very Large Projects: Extremely large or deeply nested ASCII diagrams can lead to performance issues or truncated paths. Consider breaking them into smaller segments if you encounter slowdowns.
License
Licensed under the MIT License. See the LICENSE file for details.
Acknowledgements
Thank you for using the My Directory List & Print Extension. We hope it simplifies your workflow!