Last active
May 31, 2020 15:36
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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