Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
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 at 23:43

1 Answer 1

up vote 0 down vote accepted

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()      
share|improve this answer
    
Shouldn't that last line be indented? –  Keith Thompson Mar 12 at 0:39
    
yes, my mistake the code formating screwed my up, I wrote this in the window, I will make the edit. –  Matty Mar 12 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 at 0: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 at 1:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.