What program can I use to rename files with their calculated md5 checksums? GUI or CLI Programs for Linux or Windows or scripts for DOS or the Linux terminal.
-
1I'm sorry, but what do you mean by "rename files with their calculated checksums"? You want to rename them to the value of their checksums or you want to change their name based on the value of the sums? – Seth Mar 11 '14 at 23:43
This will work in Python if it is what you are looking for. It will take and calculate an md5 for a file and then rename the file that sum. Will work on *nix/Windows/?
/usr/bin/env python
import os, hashlib
file = 'path/to/file'
def main():
h = hashlib.md5(file)
output = h.hexdigest()
os.rename( file, output)
if __name__ == '__main__':
main()
-
-
yes, my mistake the code formating screwed my up, I wrote this in the window, I will make the edit. – Matty Mar 12 '14 at 0:54
-
This would be more useful if it took the path as an argument and performed the operation recursively if the argument was a directory ;) – OregonTrail Mar 12 '14 at 0:58
-
1It would but would not be as simple of an answer. I personally would use BASH for this and take the filename as an arg and search for it with locate -b, calculate a hash with md5sum and the change the name with mv. The OP talked about x-platform so I used Python, Perl scares me. – Matty Mar 12 '14 at 1:05