A flexible and powerful tool to generate and export file structure representations from local folders. This tool supports multiple output formats and respects ignore files like .gitignore
.
You can install file-tree-export globally via npm:
npm install -g file-tree-export
Or run it directly from GitHub:
curl -s https://raw.githubusercontent.com/yourusername/file-tree-export/main/run-file-tree-export.sh | bash -s -- [options]
After installation, you can use the tool from the command line:
file-tree-export [options]
You can also use file-tree-export in your Node.js projects:
const { generateFileStructure } = require('file-tree-export');
const options = {
root: '/path/to/directory',
output: 'json',
maxFiles: 1000,
maxDepth: 10,
ignoreFile: '.gitignore'
};
const result = generateFileStructure(options);
console.log(result);
-
--root
: The root directory to start from (default: current working directory) -
--output
: Output format - 'tree', 'json', 'yaml', or 'xml' (default: 'tree') -
--maxFiles
: Maximum number of files to process (default: 2000) -
--maxDepth
: Maximum depth to traverse (default: 32) -
--ignoreFile
: Name of the ignore file to use (default: '.gitignore')
- Tree: ASCII tree representation
- JSON: Structured JSON output
- YAML: YAML representation of the file structure
- XML: XML representation of the file structure
- Generate a tree structure for the current directory:
file-tree-export
- Generate JSON output for a specific directory with a depth limit:
file-tree-export --root /path/to/directory --output json --maxDepth 5
- Generate YAML output ignoring files specified in
.npmignore
:
file-tree-export --output yaml --ignoreFile .npmignore
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.