Skip to content

Commit 065a770

Browse files
...
1 parent ab078c1 commit 065a770

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

filetree.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
def print_directory_tree(root_path, indent=""):
4+
"""
5+
Recursively prints the directory tree starting from the given root path.
6+
"""
7+
print(f"{indent} {os.path.basename(root_path)}/")
8+
9+
for entry in os.listdir(root_path):
10+
entry_path = os.path.join(root_path, entry)
11+
if os.path.isdir(entry_path):
12+
print_directory_tree(entry_path, indent + " ")
13+
else:
14+
print(f"{indent} {entry}")
15+
16+
base_directory = os.path.dirname(os.path.abspath(__file__))
17+
18+
print_directory_tree(base_directory)

0 commit comments

Comments
 (0)