Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. import os, re
  2. rm = re.compile(r".+ \(\d\).*") # r".+ - Copy.*"
  3.  
  4. def remAll(toRem):
  5. if os.path.isdir(toRem):
  6. for i in os.listdir(toRem):
  7. remAll(os.path.join(toRem, i))
  8. os.rmdir(toRem)
  9. else:
  10. os.remove(toRem)
  11.  
  12. for i in os.listdir("."):
  13. if rm.match(i):
  14. print(f"removing \"{i}\" from folder")
  15. remAll(os.path.join(".", i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement