Skip to content

Instantly share code, notes, and snippets.

@ozen
Created September 6, 2017 13:45
Show Gist options
  • Save ozen/ca9fcd68a7253bca5be12adbeea3cab2 to your computer and use it in GitHub Desktop.
Save ozen/ca9fcd68a7253bca5be12adbeea3cab2 to your computer and use it in GitHub Desktop.
import os
import random
import string
this_file = os.path.basename(__file__)
for root, dir, files in os.walk(os.path.dirname(__file__)):
for file in files:
if file != this_file:
base_name, ext = os.path.splitext(file)
ext = ext.lower()
src = os.path.join(root, file)
new_name = ''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(10))
dst = os.path.join(root, new_name + ext)
# print(dst)
os.rename(src, dst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment