Skip to content

Instantly share code, notes, and snippets.

@BradRuderman
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BradRuderman/9c64ea7dd5956dadeb87 to your computer and use it in GitHub Desktop.
Save BradRuderman/9c64ea7dd5956dadeb87 to your computer and use it in GitHub Desktop.
Photo Apps Duplicates
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