1

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.

Rublacava
  • 243
  • 3
  • 13
  • 1
    I'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

1 Answers1

1

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()      
Matty
  • 324
  • 1
  • 5
  • Shouldn't that last line be indented? – Keith Thompson Mar 12 '14 at 00:39
  • 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 00: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 00:58
  • 1
    It 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 01:05