Skip to content

Instantly share code, notes, and snippets.

@PaulleDemon
Created August 5, 2022 06:37
Show Gist options
  • Save PaulleDemon/2fc8f70cdb1929f6cc062afab67222bd to your computer and use it in GitHub Desktop.
Save PaulleDemon/2fc8f70cdb1929f6cc062afab67222bd to your computer and use it in GitHub Desktop.
walks through a specified directory listing all the files and folders in with indent.
# used to generate file overview
import os
ignore_dirs = ['.git']
ignore_files = ['.env']
def path_tree(root, inner=0):
for dir in os.listdir(root):
# print("DIR: ", root, dirs, files)
complete_path = os.path.join(root, dir)
if os.path.isdir(complete_path) and dir not in ignore_dirs:
print("\t"*inner, dir)
path_tree(complete_path, inner+1)
elif os.path.isfile(complete_path) and dir not in ignore_files:
print("\t"*inner, dir)
path_to_dir = "/home/devilman/Desktop/loner"
path_tree(path_to_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment