Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- import hashlib
- def FileCompare(file1, file2):
- f1 = open(file1, 'r')
- f2 = open(file2, 'r')
- hash1 = hashlib.md5(f1.read()).hexdigest()
- hash2 = hashlib.md5(f2.read()).hexdigest()
- f1.close()
- f2.close()
- if hash1 == hash2:
- #Compare file modification dates
- mod1 = os.stat(f1).st_mtime
- mod2 = os.stat(f2).st_mtime
- if mod1 > mod2 :
- return file1
- return file2
Add Comment
Please, Sign In to add comment