isra_BCN

Q: 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

Close

Q: export same albums from Photos

  • All replies
  • Helpful answers

Previous Page 2 of 4 last Next
  • by léonie,

    léonie léonie Feb 18, 2016 12:40 PM in response to Old Toad
    Level 10 (107,185 points)
    iCloud
    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.

  • by Jacques Rioux,

    Jacques Rioux Jacques Rioux Feb 18, 2016 1:59 PM in response to Old Toad
    Level 4 (3,418 points)
    Mac OS X
    Feb 18, 2016 1:59 PM in response to Old Toad

    Old Toad wrote:

     

    Jaques:

     

    Any way to allow the users to select more than one album at a time?

     

     

    I forgot to add the "multiple selections allowed" property to the "choose from list" command.

     

    Here's the command to select one or more albums:

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

  • by Jacques Rioux,

    Jacques Rioux Jacques Rioux Feb 18, 2016 2:13 PM in response to Old Toad
    Level 4 (3,418 points)
    Mac OS X
    Feb 18, 2016 2:13 PM in response to Old Toad

    Hi,

     

    Old Toad wrote:

     

    Jaques:

     

     

    Also have you considered adding the script to the Photos User Tips section?

    OTsig.png

     

    I cannot create User Tips, my level is not high enough.

    But if you want (or someone) to make an user tip with the base of my script, I accept with pleasure.

  • by OldToad,

    OldToad OldToad Feb 18, 2016 2:30 PM in response to Jacques Rioux
    Level 1 (4 points)
    Feb 18, 2016 2:30 PM in response to Jacques Rioux

    Terrific! 

  • by Old Toad,

    Old Toad Old Toad Feb 18, 2016 2:32 PM in response to OldToad
    Level 10 (141,132 points)
    Mac OS X
    Feb 18, 2016 2:32 PM in response to OldToad

    Opps!  Logged in the wrong account.  But terrific nevertheless.

  • by Ray20001,

    Ray20001 Ray20001 Feb 29, 2016 11:02 PM in response to Jacques Rioux
    Level 1 (0 points)
    Feb 29, 2016 11:02 PM in response to Jacques Rioux

    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.

  • by Old Toad,

    Old Toad Old Toad Mar 1, 2016 11:50 AM in response to Jacques Rioux
    Level 10 (141,132 points)
    Mac OS X
    Mar 1, 2016 11:50 AM in response to Jacques Rioux

    Jacques:

     

    I've added your script to the Photos User Tips section: Export Albums to Folders - Jacques Rioux's Script

  • by Jacques Rioux,

    Jacques Rioux Jacques Rioux Mar 1, 2016 2:27 PM in response to Ray20001
    Level 4 (3,418 points)
    Mac OS X
    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

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

  • by hanks72,

    hanks72 hanks72 Apr 23, 2016 3:03 PM in response to Jacques Rioux
    Level 1 (4 points)
    Apr 23, 2016 3:03 PM in response to Jacques Rioux

    Dear Jacques,

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

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

     

    Thanks

  • by Jacques Rioux,

    Jacques Rioux Jacques Rioux Apr 24, 2016 9:07 AM in response to hanks72
    Level 4 (3,418 points)
    Mac OS X
    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

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

  • by Old Toad,

    Old Toad Old Toad Apr 24, 2016 9:37 AM in response to GreLo
    Level 10 (141,132 points)
    Mac OS X
    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.

  • by leahcimp,

    leahcimp leahcimp May 1, 2016 1:35 PM in response to isra_BCN
    Level 1 (4 points)
    May 1, 2016 1:35 PM in response to isra_BCN

    Jacques,

     

    This script is excellent -- incredibly useful!

     

    Is it possible to sort the list of albums?  I tried using the simple_sort() subroutine (http://www.macosxautomation.com/applescript/sbrt/sbrt-05.html) but it fails.  I'm brand new to AppleScript, so it's probably my error.  

     

    Thank you.

  • by leahcimp,

    leahcimp leahcimp May 1, 2016 1:39 PM in response to Jacques Rioux
    Level 1 (4 points)
    May 1, 2016 1:39 PM in response to Jacques Rioux

    Jacques,

     

    This script is excellent -- incredibly useful!

     

    Is it possible to sort the list of albums?  I tried using the simple_sort() subroutine (http://www.macosxautomation.com/applescript/sbrt/sbrt-05.html) but it fails.  I'm brand new to AppleScript, so it's probably my error. 

     

    Thank you.

  • by Jacques Rioux,

    Jacques Rioux Jacques Rioux May 2, 2016 7:43 AM in response to leahcimp
    Level 4 (3,418 points)
    Mac OS X
    May 2, 2016 7:43 AM in response to leahcimp

    Hi,

    leahcimp wrote:

     

    Jacques,

     

    Is it possible to sort the list of albums?  I tried using the simple_sort() subroutine (http://www.macosxautomation.com/applescript/sbrt/sbrt-05.html) but it fails.

     

    Here is the basic script that shows how to use the sorting routine.

     

    -- the Photo's script

    -- script's lines

    set l to name of albums

    set l to my simple_sort(l) -- call the sorting routine, this put the output of the routine into the 'l' variable

    -- script's lines

    -- end of the Photo's script

     

    on makeFolder(tPath)

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

    end makeFolder

    on simple_sort(my_list) -- The sorting routine,  I do not include all the lines

          -- you must copy/paste it from  http://www.macosxautomation.com/applescript/sbrt/sbrt-05.html

          return the sorted_list

    end simple_sort

  • by leahcimp,

    leahcimp leahcimp May 2, 2016 9:06 AM in response to Jacques Rioux
    Level 1 (4 points)
    May 2, 2016 9:06 AM in response to Jacques Rioux

    Perfect, thank you!  

     

    (My attempt was close... didn't know about the "my" in the second set statement)

Previous Page 2 of 4 last Next