import os
import os.path

def get_dir_md5(dir_root):
    """Build a tar file of the directory and return its md5 sum"""
hash = hashlib.md5()
for dirpath, dirnames, filenames in os.walk(dir_root, topdown=True):
    dirnames.sort(key=os.path.normcase)
filenames.sort(key=os.path.normcase)
for filename in filenames:
    filepath = os.path.join(dirpath, filename)
f = open(filepath, 'rb')
for chunk in iter(lambda : f.read(65536), ''):
    hash.update(chunk)
return hash.hexdigest()
Determine whether any files have been added, removed, or modified in a directory