Advertisement
Guest User

Untitled

a guest
May 1st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. from os import listdir, rename
  2. from os.path import isfile, join
  3. from random import choice
  4. from string import ascii_lowercase, digits
  5. mypath = 'c:\\1'
  6. l = 6
  7. onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f)) and f.upper().endswith('.JPG')]
  8. for f in onlyfiles:
  9.   rnd = ''.join([choice(ascii_lowercase + digits) for _ in range(l)]+['.jpg'])
  10.   rename(join(mypath, f),join(mypath, rnd))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement