Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

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

export same albums from Photos

Hi


How can I export my library or part of my library from Photos with same album structure created?


For example, I have in Photos albums A, B, C, D, E etc


I want to export the pictures in a folders structure in OSX/finder as albums in Photos

So, in

-folder A with pictures in album A

- Folder B with pictures in album B


And so on


Thanks

Posted on May 11, 2015 7:18 AM

Reply
63 replies

Feb 18, 2016 12:40 PM in response to Old Toad

Sorry, I missed the change of direction. This discussion should be branched off so the new ideas will appear at the front.


I hope the next version of Photos will bring better support for scripting. In Aperture it was pssible to script each and everything. In Photos we would have to fall back on GUI scripting, and that is simply not safe.

Mar 1, 2016 2:27 PM in response to Ray20001

Ray20001 wrote:


Jacques script is already very useful but I just get a flat folder structure with hundreds of folders in one directory.

Is there any chance to get the entire folder structure (folder/subfolder/album name) exported?

The selection feature is not bad but simply I can't select so many folders.



Here is the script that exports the media items from folders of Photos:


----------------

set dest to "/Users/myName/Desktop/photos-Albums/" as POSIX file as text -- the destination folder (use a valid path)


tell application "Photos"

launch

-- start the export from every top folder (folders without parent)

repeat with f in folders

if parent of f is missing value then my exportPhotos(f, dest)

end repeat

end tell


on makeFolder(tPath)

do shell script "mkdir -p " & quoted form of POSIX path of tPath

end makeFolder


on exportPhotos(f, d)

tell application "Photos"

set tName to name of f

set tFolder to d & tName & ":"

repeat with a in (get albums of f) -- albums of this folder

set subFolder to tFolder & name of a & ":"

my makeFolder(subFolder) -- create folders (": subFolderName : albumName :")

with timeout of 0 seconds-- no error, if the export takes longer than two minutes

export (get media items of a) to (subFolder as alias) without using originals

end timeout

end repeat

repeat with subF in (get folders of f) -- subFolders of this folder

my exportPhotos(subF, tFolder) -- call this handler to recursively descends the directory tree

end repeat

end tell

end exportPhotos

----------------

Apr 24, 2016 9:07 AM in response to hanks72

Hi,

hanks72 wrote:


I have a question about "choose from list" command...

is it possible to list only the albums of a specific year?


It's possible (if the name of the album contains the year):

Examples:

If space character and the year is at the end of the name, use this:

set l to name of (albums whose name ends with " 2016")


If the year and the space character is at the beginning of the name, use this:

set l to name of (albums whose name starts with "2016 ")


If the space character and the year and the space character is in the name, use this:

set l to name of (albums whose name contains " 2016 ")





Otherwise, it's possible with the original date of the first media item in the album (the date defined in the information of the photo must be correct):

------------

set dest to "/Users/me/Desktop/photos-Albums/" as POSIX file as text -- the destination folder (use a valid path)

set mySpecificYear to 2016 -- define an year to filter albums


tell application "Photos"

activate

set l to {}

set tAlbs to {}

set i to 1

repeat with tAlb in (get albums) -- to filter albums (from the date of the first media item in the album)

try

set theYear to year of (get date of first media item of tAlb)

if theYear = mySpecificYear then

set end of l to "" & i & " - " & name of tAlb

set end of tAlbs to contents of tAlb -- the album ID

set i to i + 1

end if

end try

end repeat

if l is {} then return -- no albums in this list, so exit this script


set albNames to choose from list l with prompt "Select some albums"

if albNames is not false then -- not cancelled

set tc to count albNames

repeat with i from 1 to tc

set n to (word 1 of (item i of albNames)) as integer

set tAlb to item n of tAlbs

set tName to name of tAlb

set tFolder to dest & tName

my makeFolder(tFolder) -- create a folder named (the name of this album) in dest

export (get media items of tAlb) to (tFolder as alias) without using originals

end repeat

end if

end tell


on makeFolder(tPath)

do shell script "mkdir -p " & quoted form of POSIX path of tPath

end makeFolder

------------

Apr 24, 2016 9:37 AM in response to GreLo

With his permission I've posted Jacques' script in the Photos for Mac User Tips section.


Export Albums to Folders - Jacques Rioux's Script


You can download a compiled version of the script as an application from this tutorial site: P01 - Applescripts from Photos’ User Tips Compiled as Applications


It does let you chose multiple albums in the presented list by Command-clicking on them and export to folders with the same name.

export same 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.