Last active
March 24, 2017 18:18
-
-
Save TimSC/202ea7ef04fa0e53f8e38f5463ef2734 to your computer and use it in GitHub Desktop.
Hash files under working folder recursively for hard drive read test.
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
| #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