Last active
August 29, 2015 14:19
-
-
Save BradRuderman/9c64ea7dd5956dadeb87 to your computer and use it in GitHub Desktop.
Photo Apps Duplicates
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
from os.path import expanduser | |
import os | |
import hashlib | |
#Replace the following line with the location of your photo's library. The default location is the home | |
#directory. | |
PATH_TO_PHOTOS_LIBRARY = expanduser("~") + '/Pictures/Photos Library.photoslibrary' | |
hashes = [] | |
for subdir, dirs, files in os.walk(PATH_TO_PHOTOS_LIBRARY + '/Masters'): | |
for file in files: | |
md5_returned = None | |
with open(os.path.join(subdir, file)) as file_to_check: | |
# read contents of the file | |
data = file_to_check.read() | |
# pipe contents of the file through | |
md5_returned = hashlib.md5(data).hexdigest() | |
if md5_returned in hashes: | |
print(os.path.join(subdir, file)) | |
else: | |
hashes.append(md5_returned) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment