Created
February 20, 2019 21:53
-
-
Save Shivam60/78db838293425263c7b88f444556a7ec to your computer and use it in GitHub Desktop.
This file contains 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
''' | |
This code finds the md5 sum of all files present in a folder. | |
It assumes the path is valid. | |
''' | |
import os | |
import hashlib | |
path=r"I:\shivam\big_dataset" | |
def md5(fname): | |
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() | |
def FindMd5SumOfAllFilesPresent(path): | |
os.chdir(path) | |
print("The File Names With MD5 Sum are. ") | |
for files in os.listdir(): | |
print(str(files),md5(files)) | |
FindMd5SumOfAllFilesPresent(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment