Created
October 31, 2014 07:10
-
-
Save bwesterb/a699d64fe1d7d4f78bb9 to your computer and use it in GitHub Desktop.
recurse through directories
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
#!/bin/python | |
import os | |
import os.path | |
base_path = '.' | |
todo = [base_path] | |
while todo: | |
current_dir = todo.pop() | |
for child_name in os.listdir(current_dir): | |
child = os.path.join(current_dir, child_name) | |
if os.path.isdir(child): | |
todo.append(child) | |
continue | |
if os.path.isfile(child): | |
# Do the thing with the file | |
# .... | |
print child |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment