directory-structure
Print a directory tree structure in your Python code.
Download
You can simply:
pip install directory-structure
Or you can also:
- Clone the repository to your local machine.
- Enter the directory.
- Download necessary modules/libraries.
git clone https://github.com/gabrielstork/directory-structure.git
cd directory-structure
pip install -r requirements.txt
Examples
from directory_structure import Tree
Using absolute path as an argument.
path = Tree('C:/Users/User/Desktop/directory-structure', absolute=True)
print(path)
๐ C:
|_๐ Users
|_๐ User
|_๐ Desktop
|_๐ directory-structure
|_๐ .git
|_๐ directory_structure
|_๐ .gitignore
|_๐ LICENSE
|_๐ pyproject.toml
|_๐ README.md
|_๐ requirements.txt
|_๐ setup.py
path = Tree('C:/Users/User/Desktop/directory-structure', absolute=False)
print(path)
๐ directory-structure
|_๐ .git
|_๐ directory_structure
|_๐ .gitignore
|_๐ LICENSE
|_๐ pyproject.toml
|_๐ README.md
|_๐ requirements.txt
|_๐ setup.py
Accessing a folder in current working directory.
path = Tree('./directory_structure', absolute=True)
print(path)
๐ C:
|_๐ Users
|_๐ User
|_๐ Desktop
|_๐ directory-structure
|_๐ directory_structure
|_๐ tree.py
|_๐ __init__.py
path = Tree('./directory_structure', absolute=False)
print(path)
๐ directory_structure
|_๐ tree.py
|_๐ __init__.py
Getting all from the directory where your current working directory is.
path = Tree('../', absolute=True)
print(path)
๐ C:
|_๐ Users
|_๐ User
|_๐ Desktop
|_๐ directory-structure
|_๐ Discord.lnk
|_๐ Spotify.lnk
|_๐ Steam.lnk
|_๐ Telegram.lnk
|_๐ Visual Studio Code.lnk
|_๐ WhatsApp.lnk
path = Tree('../', absolute=False)
print(path)
๐ Desktop
|_๐ directory-structure
|_๐ Discord.lnk
|_๐ Spotify.lnk
|_๐ Steam.lnk
|_๐ Telegram.lnk
|_๐ Visual Studio Code.lnk
|_๐ WhatsApp.lnk