Skip to content

Instantly share code, notes, and snippets.

@laingc
Created May 18, 2017 18:11
Show Gist options
  • Save laingc/cc6d34580541d3b96d8054a7b70bf9de to your computer and use it in GitHub Desktop.
Save laingc/cc6d34580541d3b96d8054a7b70bf9de to your computer and use it in GitHub Desktop.
#!/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