Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, re
- rm = re.compile(r".+ \(\d\).*") # r".+ - Copy.*"
- def remAll(toRem):
- if os.path.isdir(toRem):
- for i in os.listdir(toRem):
- remAll(os.path.join(toRem, i))
- os.rmdir(toRem)
- else:
- os.remove(toRem)
- for i in os.listdir("."):
- if rm.match(i):
- print(f"removing \"{i}\" from folder")
- remAll(os.path.join(".", i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement