Created
September 13, 2011 21:44
-
-
Save eloyz/1215258 to your computer and use it in GitHub Desktop.
Loop through files then delete directories with digit names
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
""" | |
Loop through files in current directory | |
Delete all directories that are named with digits | |
""" | |
import os | |
import shutil | |
for root, dirs, files in os.walk('.'): | |
basename = os.path.basename(root) | |
if os.path.isdir(basename) and basename.isdigit(): | |
print root | |
shutil.rmtree(root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment