Skip to content

Instantly share code, notes, and snippets.

@ramayac
Created May 4, 2012 15:50
Show Gist options
  • Save ramayac/2595665 to your computer and use it in GitHub Desktop.
Save ramayac/2595665 to your computer and use it in GitHub Desktop.
Renombra a MD5 los archivos que cumplan con un patrón de búsqueda especificado.
import glob, os, hashlib
SALT = 'mysalt'
IMAGE_PATH = r'C:/file/path/'
def renombrar(dir, patron):
for rutayArchivo in glob.iglob(os.path.join(dir, patron)):
title, ext = os.path.splitext(os.path.basename(rutayArchivo))
m = hashlib.md5()
m.update (SALT + title)
newtitle = m.hexdigest()
os.rename(rutayArchivo, os.path.join(dir, newtitle + ext))
renmd5(IMAGE_PATH, r'*.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment