Advertisement
Peaser

Duplicate file detector

Aug 1st, 2015
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import os, hashlib
  2. path = "<PATH>/"
  3.  
  4. files = {}
  5. yup = {}
  6.  
  7. for file in os.listdir(path):
  8.  
  9.   file = path+file
  10.  
  11.   hash = hashlib.md5(open(file, "rb").read()).hexdigest()
  12.   if hash in files.values():
  13.     yup[file] = hash
  14.   else:
  15.     files[file] = hash
  16.  
  17. def outputToFile():
  18.   # Write shit to a text file.
  19.   with open("outf.txt", "w") as out:
  20.     for i in yup:
  21.       out.write("{} - {}\n".format(i, yup[i]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement