Created
November 12, 2018 21:51
-
-
Save wrenoud/8dafab15884cc49303d009ce070f35f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import hashlib | |
def getHashes(folder): | |
hashes = {} | |
for root, dirs, files in os.walk(folder): | |
for file in files: | |
filepath = os.path.join(root,file) | |
hash_md5 = hashlib.md5() | |
with open(filepath, "rb") as f: | |
for chunk in iter(lambda: f.read(4096), b""): | |
hash_md5.update(chunk) | |
hashes[hash_md5.hexdigest()] = filepath | |
return hashes | |
left = getHashes("/home/pi/Downloads") | |
right = getHashes("/home/pi/Downloads") | |
for hsh, filepath in left.items(): | |
if hsh in right: | |
print("Match:", filepath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment