dirtree.py is a Python utility toolkit designed for effective directory navigation and visualization. It offers various functions to suit different visualization needs, allowing users to explore and understand project hierarchies. Whether you need a simple tree view or a beautified structure, dirtree.py has you covered.
This section allows users to quickly visualize their directory structure using the beautify tree structure feature of dirtree.py
. The example command and output illustrate how effortlessly you can beautify and understand the hierarchy of your project.
python dirtree.py beautify /path/to/my-nodejs-app
Example Output:
- my-nodejs-app
|- config
| |- appConfig.js
| |- database.js
|- controllers
| |- database.js
| |- postController.js
|- middlewares
| |- authentication.js
| |- authorization.js
|- models
| |- post.js
| |- user.js
|- package.json
|- public
| |- images
| |- styles
|- routes
| |- api
| | |- posts.js
| | |- users.js
| |- index.js
| |- web
| | |- auth.js
| | |- home.js
|- server.js
|- services
|- utils
- Simple Tree: Display a simple tree view of the directory.
- Absolute Path Tree (Platform-Independent): Display the absolute path tree using forward slashes or backward slashes, automatically adjusting to the underlying operating system.
- Relative Path Tree (Platform-Independent): Display the relative path tree using forward slashes or backward slashes, automatically adjusting to the underlying operating system.
- Absolute Path Tree (User-Defined Style): Display the absolute path tree with a user-defined path style (Unix or Windows).
- Relative Path Tree (User-Defined Style): Display the relative path tree with a user-defined path style (Unix or Windows).
- Directory Tree Structure: Display a structured tree view of the directory.
- Beautify Tree Structure: Display a beautified tree view of the directory.
- Python 3.x
Display a simple tree view of the directory.
python dirtree.py simple /path/to/directory
Example Output:
directory/
file1.txt
file2.txt
subdirectory/
file3.txt
Display the absolute path tree using forward slashes or backward slashes depending upon which operating system are you using. This script automatically adjusts to the underlying operating system, using forward slashes for Unix-like systems and backward slashes for Windows systems.
python dirtree.py abs_pi /path/to/directory
Example Output for Windows:
E:\path\to\directory
E:\path\to\directory\file1.txt
E:\path\to\directory\file2.txt
E:\path\to\directory\subdirectory
E:\path\to\directory\subdirectory\file3.txt
Example Output for Linux:
E:/path/to/directory
E:/path/to/directory/file1.txt
E:/path/to/directory/file2.txt
E:/path/to/directory/subdirectory
E:/path/to/directory/subdirectory/file3.txt
Display the relative path tree using forward slashes or backward slashes depending upon which operating system are you using. This script automatically adjusts to the underlying operating system, using forward slashes for Unix-like systems and backward slashes for Windows systems.
python dirtree.py rel_pi /path/to/directory
Example Output for Windows:
directory
directory\file1.txt
directory\file2.txt
directory\subdirectory
directory\subdirectory\file3.txt
Example Output for Linux:
directory
directory/file1.txt
directory/file2.txt
directory/subdirectory
directory/subdirectory/file3.txt
Display the absolute path tree with a user-defined path style. This script enables users to explicitly specify the desired path style (Unix or Windows), offering flexibility and consistency across different operating systems.
Change the --path_style parameter as needed, '/' for unix like path formatting and '' for windows like path format.
python dirtree.py abs /path/to/directory --path_style /
Example Output:
E:/path/to/directory
E:/path/to/directory/file1.txt
E:/path/to/directory/file2.txt
E:/path/to/directory/subdirectory
E:/path/to/directory/subdirectory/file3.txt
Display the absolute path tree with a user-defined path style. This script enables users to explicitly specify the desired path style (Unix or Windows), offering flexibility and consistency across different operating systems.
Change the --path_style parameter as needed, '/' for unix like path formatting and '' for windows like path format.
python dirtree.py rel /path/to/directory --path_style /
Example Output:
directory
directory/file1.txt
directory/file2.txt
directory/subdirectory
directory/subdirectory/file3.txt
Display a structured tree view of the directory.
python dirtree.py tree /path/to/directory
Example Output:
+-- directory/
+-- file1.txt
+-- file2.txt
+-- subdirectory/
+-- file3.txt
Display a beautified tree view of the directory.
python dirtree.py beautify /path/to/directory
Example Output:
- directory/
|- file1.txt
|- file2.txt
|- subdirectory/
|- file3.txt
- Adjust the
/path/to/directory
to the actual path you want to visualize. - Use the
--path_style
option to specify the path style for formatting ("auto", "/", ""). - Choose the desired function based on your visualization requirements.