Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Exporting albums from Photos

I need to export all my albums from Photos. I've got about a thousand, which will take me a couple full days to get through, so I need some way to automate it. Unfortunately, Photos eliminated this option. Does anyone know of an AppleScript that could collect all the album names and export each to a same-named folder, or at least the pieces I'd need to put together to make a script that would do this?

Photos-OTHER, OS X Yosemite (10.10.5)

Posted on Oct 7, 2015 7:53 AM

Reply
Question marked as Best reply

Posted on Oct 8, 2015 10:39 AM

This site may help you get started.


SG

19 replies

Oct 9, 2015 1:54 PM in response to Magmadar

I don't know much about Photos.app. However, the following script, which I have tested with a very small photo library containing only 12 photos and 4 albums, seems to do what you are asking for. Photos.app must already be open before running the script from the Script Editor window. Maybe it could give you some new ideas.


set theFolderName to "Exported albums"

set theDestinationFolder to POSIX file (POSIX path of file ((path todesktopastext) & theFolderName & ":"))

tell application "Finder"

if not (existstheDestinationFolder) then

makenewfolderatdesktopwith properties {name:theFolderName}

end if

end tell

tell application "Photos"

activate

set myAlbums to {}

repeat with thisContainer in containers

set thisContainer to contents of thisContainer

if name of thisContainer is not in {"Favorites", "Last Import"} then

copy thisContainer to the end of myAlbums

end if

end repeat

repeat with thisAlbum in myAlbums

set thisAlbum to contents of thisAlbum

set thisName to name of thisAlbum

set thesePhotos to media items of thisAlbum

try

tell application "Finder"

makenewfolderattheDestinationFolderwith properties {name:thisName}

set thisExportedAlbum to result as alias

end tell

exportthesePhotostothisExportedAlbum-- with using originals ?

end try

end repeat

end tell

say "Done"

Oct 9, 2015 1:57 PM in response to Pierre L.

From what I understand this should do it, but I do keep getting an error right at the start - "Can't get every media item of container id \"U%8[...]9WA\"." number -1728 from every media item of container id "U%8[...]9WA"

Any clue what's going on there? It's happened on all the libraries I've tried so far. (3 of varying size)

Jan 30, 2016 11:02 PM in response to Tortle2

I've tried the script with the "iPhoto Events" added to the excluded list. It executes without any eror, but then I find many of the albums are not actually exported. In fact, if I repeat the execution a second time -previously deleting the "Exported albums" folder", of course-, no album is actually exported. I get just a bunch of empty folders named as the albums...


I removed the try - end try lines so that any export error arises. I get this error on the second album to export (sorry, my Mac is in Spanish...):


error "Photos ha detectado un error: No puede obtenerse media item id \"Ii4yZWimRN2Pf29EeyUhtA\" of container id \"OeVPBeZ7RPCHJ++MbE%kWQ\"." number -1728 frommedia itemid "Ii4yZWimRN2Pf29EeyUhtA" of containerid "OeVPBeZ7RPCHJ++MbE%kWQ"

Then I remove the "Exported albums" folder, try again, and get a different error:

error "Photos ha detectado un error: Error en el gestor de eventos Apple." number -10000

On the third attempt, I get the first error on the first album...

This script has a completely arbitrary behaviour in my system each time is executed! Any clue about what's happening? Why was the try - end try included in the first place?

Yosemite 10.10.5 - Photos 1.0.1 - 14000+ photos and videos

Feb 13, 2016 1:04 AM in response to Magmadar

This is the code I'm testing in Yosemite with no luck. Note the try - end try lines are commented, so that you don't ignore any error. Should it really work? Does it work on El Capitan?


set theFolderName to "Exported albums"

set theDestinationFolder to POSIX file (POSIX path of file ((path todesktopastext) & theFolderName & ":"))

tell application "Finder"

if not (existstheDestinationFolder) then


makenewfolderatdesktopwith properties {name:theFolderName}

end if

end tell

tell application "Photos"

activate

set myAlbums to {}

repeat with thisContainer in containers

set thisContainer to contents of thisContainer

if name of thisContainer is not in {"Favorites", "Last Import", "iPhoto Events"} then

copy thisContainer to the end of myAlbums

end if

end repeat

delay 1

repeat with thisAlbum in myAlbums


log "Exporting " & name of thisAlbum

set thisAlbum to contents of thisAlbum

set thisName to name of thisAlbum

set thesePhotos to media items of thisAlbum


--try

tell application "Finder"


makenewfolderattheDestinationFolderwith properties {name:thisName}

set thisExportedAlbum to result as alias

end tell


exportthesePhotostothisExportedAlbum with using originals


--end try

end repeat

end tell

say "Done"

Feb 13, 2016 6:53 AM in response to Zeezah

Hi Zeezah,


I have tested the original script again (without Tortle2's modification), using Photos 1.3 (350.23.0) under OS X 10.11.3, and it worked flawlessly.

Here's exactly how I have proceeded:

1. Create a new photos library in the Pictures folder entitled “Test Photos Library”.

2. Drag and drop 100 JEPG photos (each 4896 x 3672 pixels) into the new library.

3. Create 5 new empty albums entitled “Album 1”, “Album 2”, …, “Album 5”.

4. Drag and drop 20 photos in each album.

5. Quit Photos.

6. Make a copy of the new library.

7. Reopen Photos and select Photos in the sidebar.

8. Run the original script from the Script Editor window.


The try block is in case the “Exported Albums” folder already exists on desktop.

Feb 15, 2016 1:26 PM in response to Pierre L.

If I test with the same script, it creates a folder for each album, but most of them are empty. Only some albums are actually exported 😟

I guess it must be a bug in Photos 1.0.1 (215.65.0).


How can I create a new Photos library for testing? I don't find the option to change the library. When I rename my library with Photos closed, and then open Photos, it detects the library with the new name...

Exporting albums from Photos

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.