Skip to content

Instantly share code, notes, and snippets.

@edbrannin
Created September 9, 2017 10:41
Show Gist options
  • Save edbrannin/94c4d31176e3fd044e3b6978db5b6a27 to your computer and use it in GitHub Desktop.
Save edbrannin/94c4d31176e3fd044e3b6978db5b6a27 to your computer and use it in GitHub Desktop.
album_cleanse.py
import photos
import dialogs
delete_these = list()
for album in photos.get_albums():
size = len(album.assets)
to_delete = size == 0
# print "{} {} {}".format(album.title, size, to_delete and '***')
if to_delete:
if album.can_delete:
delete_these.append(album)
print('Will delete {} albums.'.format(len(delete_these)))
segment_size = min((len(delete_these)/4, 25))
for i, album in enumerate(sorted(delete_these, key=lambda x:x.title)):
if i % segment_size == 0:
dialogs.alert(
'Continue?',
'progress: {} of {} ({}%)'.format(
i, len(delete_these),
int(i*100.0/len(delete_these))
),
'Yes'
)
album.delete()
print ' Deleted {}'.format(album.title)
print 'Done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment