Skip to content

Instantly share code, notes, and snippets.

@pallabpain
Last active May 31, 2020 15:36
Show Gist options
  • Save pallabpain/1b97f029237657b187c61766a8ff5fd2 to your computer and use it in GitHub Desktop.
Save pallabpain/1b97f029237657b187c61766a8ff5fd2 to your computer and use it in GitHub Desktop.
A simple Python script to perform a walk on a directory and store the directory tree as a list
import os
def generate_directory_tree(dir_path):
paths = []
for root, _, files in os.walk(dir_path):
paths.append(root)
paths.extend(os.path.join(root, _file) for _file in files)
return paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment