Skip to content

Instantly share code, notes, and snippets.

@eloyz
Created September 13, 2011 21:44
Show Gist options
  • Save eloyz/1215258 to your computer and use it in GitHub Desktop.
Save eloyz/1215258 to your computer and use it in GitHub Desktop.
Loop through files then delete directories with digit names
"""
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