Generate a directory structure with a simple copy and paste.
Features
- 📂 Extract from Any Directory: Support extracting file tree from the root or any subdirectory.
- 🔍 File Filtering: Automatically filter files based on your project's
.gitignore
or custom ignore rules.
- 🛠️ Highly Customizable: Numerous configuration options to tailor the output.
- 📝 Multiple Output Formats: Generate tree structure in ASCII or JSON format.
- 💾 File Size Information: Optionally include file sizes in the output.
- ⬇️ Depth Control: Set a maximum depth for the generated tree structure.
Usage
- Right-click on a folder in the VS Code file explorer
- Select "Copy File Tree" or "Copy File Tree From This Directory"
- The file tree will be copied to your clipboard
- Paste the tree wherever you need it
Alternatively, use the keyboard shortcut Ctrl+Alt+C
to copy the file tree of the entire project.
root/
├── .env
├── .gitignore
├── asset/
│ ├── icon/
│ │ └── icon.png
│ ├── logo.svg
│ └── logo_text.svg
├── dist/
│ ├── index.d.ts
│ ├── main.esm.js
│ ├── main.js
│ ├── main.min.js
│ ├── main.min.js.map
│ └── main.umd.js
├── file_tree.txt
├── package-lock.json
├── package.json
├── README.md
├── rollup.config.js
└── src/
├── config.js
├── error.js
├── index.js
├── render.js
├── util.js
└── validate.js
Configuration
You can customize the extension's behavior through VS Code settings.
To access these settings, go to File
> Preferences
> Settings
and search for "File Tree Extractor"
.
Description:
This setting allows you to specify a list of files and folders that should be ignored when generating the file tree. It is useful if you want to exclude certain files or folders from the generated file tree, such as temporary or cached files, or other directories that are not part of your project's main structure.
Default Value:
[".git", "node_modules"]
settings.json
"fileTreeExtractor.ignoredItems": [".git", "node_modules", "dist", "**/src"]
root/
├── .env
├── .gitignore
├── asset/
│ ├── icon/
│ │ └── icon.png
│ ├── logo.svg
│ └── logo_text.svg
├── package-lock.json
├── package.json
├── README.md
└── rollup.config.js
Description:
Specifies the method to ignore files and folders when generating the file tree structure.
Options:
"gitignore"
| "ignoredItems"
| "both"
Default Value:
"ignoredItems"
settings.json
"fileTreeExtractor.ignoredBy": "ignoredItems"
"gitignore"
: The extension will use the .gitignore
file to determine which files and folders to ignore.
"ignoredItems"
: The extension will use "fileTreeExtractor.ignoredItems"
specified in the extension settings.
"both"
: The extension will use both "ignoredItems"
and "gitignore"
method.
Description:
The number of spaces to use for indenting each level in the generated file tree.
Default Value:
1
settings.json
"fileTreeExtractor.indent": 4
root/
├──── .env
├──── .gitignore
├──── asset/
│ ├──── icon/
│ │ └──── icon.png
│ ├──── logo.svg
│ └──── logo_text.svg
├──── package-lock.json
├──── package.json
├──── README.md
└──── rollup.config.js
Description:
Include file sizes in the generated tree.
Options:
"true"
| "false"
Default Value:
"false"
settings.json
"fileTreeExtractor.showFileSize": true
root/
├── .env (0 Bytes)
├── .gitignore (135 Bytes)
├── asset/
│ ├── icon/
│ │ └── icon.png (1.36 MB)
│ ├── logo.svg (677 Bytes)
│ └── logo_text.svg (1.71 KB)
├── package-lock.json (217.22 KB)
├── package.json (1.27 KB)
├── README.md (0 Bytes)
└── rollup.config.js (1.27 KB)
Description:
Sets the maximum depth of the generated file tree structure. Using a value of -1
will generate the tree with unlimited depth.
Default Value:
-1
settings.json
"fileTreeExtractor.maxDepth": 3
root/
├── .env
├── .gitignore
├── asset/
│ ├── icon/
│ ├── logo.svg
│ └── logo_text.svg
├── package-lock.json
├── package.json
├── README.md
└── rollup.config.js
Description:
The format of the output tree structure.
Options:
"ascii"
| "json"
Default Value:
"ascii"
settings.json
"fileTreeExtractor.outputFormat": "json"
{
"name": "root",
"type": "directory",
"children": [
{
"name": "asset",
"type": "directory",
"children": [
{
"name": "icon",
"type": "directory",
"children": [
{
"name": "icon.png",
"type": "file",
"size": "104.36 KB"
}
]
},
{
"name": "logo.svg",
"type": "file",
"size": "677 Bytes"
},
]
},
{
"name": "package.json",
"type": "file",
"size": "1.27 KB"
},
]
}
Commands
File Tree Extractor: Copy File Tree
: Copy the file tree of the entire project.
File Tree Extractor: Copy File Tree From This Directory
: Copy the file tree starting from the selected directory.
File Tree Extractor: Report an Issue
: Open the GitHub issue page to report a problem or suggest a feature.
Keyboard Shortcuts
Ctrl+Alt+C
: Copy the file tree of the entire project.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Reporting Issues
If you encounter any problems or have suggestions, please use the "Report an Issue" command in VS Code, or open an issue on GitHub repository.
License
This extension is licensed under the MIT License.