Created
May 4, 2012 15:50
-
-
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.
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 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