osx - Loop through every photo in Photos -


i want clean photos library , move iphone screenshots new album, way can through them , delete want.

now first wanted make smart album in photos, seems photos can't filter on dimensions of image, started applescript editor :).

i created following script, works on "test album" created:

tell application "photos"      set source_album_name "test album"     set target_album_name "screenshots"      set target_width 640     set target_height 1136      if not (exists container named target_album_name)         make new album named target_album_name     end if      set target_album container target_album_name     set source_album container source_album_name      set imagelist {}      repeat photo in media items in source_album          if width of photo = target_width , height of photo = target_height             set end of imagelist photo         end if      end repeat      add imagelist target_album  end tell 

this script loops through album named test album , compares height , width dimensions of iphone 5s. when match, adds photo screenshots library. no problems there.

now want run script on entire photo collection, changed line repeat photo in media items in source_album repeat photo in every media item.

this generates error once past first item (photos got error: can’t item 2 of every media item. invalid index).

after changed code to:

set all_images every media item repeat photo in all_images 

but after loading while, script exits code -10000, because of amount of photos in library (27.000).

is there way page through set this?

edit: changing set line contain better query has same effect, resulting in appleevent handler failed error number -10000.

set all_images every media item width = target_width , height = target_height

the -10000 error due bug in photos 1.0. i've filed apple radar 20626449 (on openradar @ http://openradar.appspot.com/radar?id=6090497735000064). error intermittent, more photos there in library, more occur on given scripting command.

there no totally reliable way around error, 1 thing seems if "all photos" album selected in photos before starting script. unfortunately photos applescript suite doesn't have ability select album, you'll need manually before starting script.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -