Created
May 18, 2017 18:11
-
-
Save laingc/cc6d34580541d3b96d8054a7b70bf9de 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
#!/usr/env/python | |
import hashlib, os | |
def md5(fname): | |
try: | |
hash_md5 = hashlib.md5() | |
with open(fname, "rb") as f: | |
for chunk in iter(lambda: f.read(4096), b""): | |
hash_md5.update(chunk) | |
return hash_md5.hexdigest() | |
except IsADirectoryError: | |
return None | |
dir0 = 'DIRECTORY_GOES_HERE' | |
dir1 = 'DIRECTORY_GOES_HERE'' | |
hashes0 = {md5(os.path.join(dir0,filename)) for filename in os.listdir(dir0)} | |
hashes1 = {md5(os.path.join(dir1,filename)) for filename in os.listdir(dir1)} | |
assert hashes0 == hashes1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment