Created
September 6, 2017 13:45
-
-
Save ozen/ca9fcd68a7253bca5be12adbeea3cab2 to your computer and use it in GitHub Desktop.
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
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