DEMO:
# -*- coding:utf-8 -*-
import os
import md5
def rename(path):
os.chdir(path)
for f in os.listdir(path):
newname = getMD5(f)
os.rename(f+"", newname+".jpg")
print(newname+".jpg")
def getMD5(src):
m1 = md5.new()
m1.update(src)
return m1.hexdigest()
if __name__ == '__main__':
path = 'D:\\wallpaper'
rename(path)