Created
April 30, 2013 17:55
-
-
Save bobhancockgist/5490527 to your computer and use it in GitHub Desktop.
Pythons: all files in a tree
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 | |
# Assign your top level directory to home | |
home = "/Users/rhancock" | |
for dirpath, dirs, files in os.walk(home, topdown=True): | |
for dr in dirs: | |
fullpath_d = os.path.join(dirpath, dr) | |
for fname in os.listdir(fullpath_d): | |
# do something with the file here, I just printed the name. | |
print(os.path.join(fullpath_d, fname)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment