Skip to content

Instantly share code, notes, and snippets.

@nitej
Created September 30, 2017 16:24
Show Gist options
  • Save nitej/b56ee898174025e53c4d44a199613dd2 to your computer and use it in GitHub Desktop.
Save nitej/b56ee898174025e53c4d44a199613dd2 to your computer and use it in GitHub Desktop.
rmPhotosSaveFav.py
import photos
albums = photos.get_albums()
favs = photos.get_favorites_album()
albums.append(favs)
all_assets = photos.get_assets()
all_videos = photos.get_assets(media_type='video')
all_assets += all_videos
print "all photos " + str(len(all_assets))
for album in albums:
album_assets = album.assets
for obj in xrange(len(all_assets)-1,-1,-1):
if not all_assets[obj].can_delete:
del all_assets[obj]
elif all_assets[obj] in album_assets:
del all_assets[obj]
print album.title,
print " removed ",
print len(all_assets)
photos.batch_delete(all_assets)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment