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

closed as off-topic by Ƭᴇcʜιᴇ007, mdpc, fixer1234, Michael Kjörling, random May 13 at 22:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking product, service, or learning material recommendations are off-topic because they become outdated quickly and attract opinion-based answers. Instead, describe your situation and the specific problem you're trying to solve. Share your research. Here are a few suggestions on how to properly ask this type of question." – Ƭᴇcʜιᴇ007, mdpc, Michael Kjörling, random
If this question can be reworded to fit the rules in the help center, please edit the question.

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 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 '14 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 '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
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 1:05

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