-
Notifications
You must be signed in to change notification settings - Fork 0
/
FolderFlow.py
31 lines (22 loc) Β· 879 Bytes
/
FolderFlow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
def print_folder_structure(folder_path, prefix=""):
contents = os.listdir(folder_path)
contents.sort() # To ensure contents are printed in order
for index, item in enumerate(contents):
item_path = os.path.join(folder_path, item)
# Ignore hidden files and directories (starting with a dot)
if item.startswith('.'):
continue
if index == len(contents) - 1:
connector = "βββ "
new_prefix = prefix + " "
else:
connector = "βββ "
new_prefix = prefix + "β "
print(prefix + connector + item)
if os.path.isdir(item_path):
print_folder_structure(item_path, new_prefix)
# Get the current working directory
folder_path = os.getcwd()
print(os.path.basename(folder_path) + "/")
print_folder_structure(folder_path)