Skip to content

Instantly share code, notes, and snippets.

@bobhancockgist
Created April 30, 2013 17:55
Show Gist options
  • Save bobhancockgist/5490527 to your computer and use it in GitHub Desktop.
Save bobhancockgist/5490527 to your computer and use it in GitHub Desktop.
Pythons: all files in a tree
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