DirTree is a command-line tool for visualizing directory structures. It provides customizable output, showing file sizes, permissions, and colorized formatting. You can limit traversal depth and ignore specified directories. DirTree is perfect for quickly understanding complex file systems and aiding in documentation or debugging.
- Display directory structure with visual pointers.
- Show file sizes in human-readable format.
- Include file permissions.
- Colorized output for better readability.
- Limit directory traversal depth.
- Ignore specified directories.
To use DirTree, follow these steps:
-
Ensure you have Python installed:
- You need Python 3.x to run DirTree.
-
Install required packages:
- DirTree uses the
termcolor
package for colorized output. Install it using pip:pip install termcolor
- DirTree uses the
-
Download the script:
- Save the script as
dirtree.py
.
- Save the script as
-
Run the script:
- Open a terminal and navigate to the directory containing
dirtree.py
. - Use the following command to run the script:
python dirtree.py [options] <directory>
- Open a terminal and navigate to the directory containing
directory
: The root directory to print the structure of (default is the current directory).-s
,--size
: Show file sizes.-d
,--depth
: Limit the depth of directory traversal.-c
,--color
: Colorize the output.-p
,--permissions
: Include file permissions.-o
,--output
: Output the directory structure to a file.-i
,--ignore
: Ignore specified directories.
-
Print the structure of the current directory:
python dirtree.py .
-
Print the structure with file sizes and colorized output:
python dirtree.py -s -c .
-
Print the structure with a depth limit of 2:
python dirtree.py -d 2 .
-
Print the structure, including file permissions:
python dirtree.py -p .
-
Print the structure, ignoring specific directories:
python dirtree.py -i node_modules .venv .
-
Output the structure to a file:
python dirtree.py -o output.txt .
This project is licensed under the MIT License.