Skip to content

Instantly share code, notes, and snippets.

@TimSC
Last active March 24, 2017 18:18
Show Gist options
  • Select an option

  • Save TimSC/202ea7ef04fa0e53f8e38f5463ef2734 to your computer and use it in GitHub Desktop.

Select an option

Save TimSC/202ea7ef04fa0e53f8e38f5463ef2734 to your computer and use it in GitHub Desktop.
Hash files under working folder recursively for hard drive read test.
#Hash files under working folder recursively
#for hard drive read test.
#Released as CC0
from __future__ import print_function
import hashlib
import os
import time
if __name__=="__main__":
while True:
w = os.walk(".")
for pth, folderList, fileList in w:
#if pth[:5] == "./dev":
# continue
for fina in fileList:
fullFina = os.path.join(pth, fina)
try:
m = hashlib.md5()
fi = open(fullFina, "rb")
d = fi.read(1000000)
while len(d) > 0:
m.update(d)
d = fi.read(1000000)
print (fullFina, m.hexdigest())
except IOError:
print ("Error opening", fullFina)
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment