Created
March 20, 2017 16:29
-
-
Save NicholasMurray/6bb369f67dd16f9ce81314b7f602fe68 to your computer and use it in GitHub Desktop.
Find subdirectories in python
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 | |
import sys | |
walk_dir = 'directory_parent' | |
# If your current working directory may change during script execution, it's recommended to | |
# immediately convert program arguments to an absolute path. Then the variable root below will | |
# be an absolute path as well. Example: | |
# walk_dir = os.path.abspath(walk_dir) | |
print('walk_dir (absolute) = ' + os.path.abspath(walk_dir)) | |
for root, subdirs, files in os.walk(walk_dir): | |
print('--\nroot = ' + root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment