-
All replies
-
Helpful answers
-
Feb 18, 2016 12:40 PM in response to Old Toadby léonie,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.
-
Feb 18, 2016 1:59 PM in response to Old Toadby Jacques Rioux,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
-
-
-
Feb 18, 2016 2:32 PM in response to OldToadby Old Toad,Opps! Logged in the wrong account. But terrific nevertheless.
-
Feb 29, 2016 11:02 PM in response to Jacques Riouxby Ray20001,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.
-
Mar 1, 2016 11:50 AM in response to Jacques Riouxby Old Toad,Jacques:
I've added your script to the Photos User Tips section: Export Albums to Folders - Jacques Rioux's Script
-
Mar 1, 2016 2:27 PM in response to Ray20001by Jacques Rioux,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 23, 2016 3:03 PM in response to Jacques Riouxby hanks72,Dear Jacques,
I have a question about "choose from list" command...
is it possible to list only the albums of a specific year?
Thanks
-
Apr 24, 2016 9:07 AM in response to hanks72by Jacques Rioux,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 GreLoby Old Toad,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.
-
May 1, 2016 1:35 PM in response to isra_BCNby leahcimp,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.
-
May 1, 2016 1:39 PM in response to Jacques Riouxby leahcimp,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.
-
May 2, 2016 7:43 AM in response to leahcimpby Jacques Rioux,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
-
May 2, 2016 9:06 AM in response to Jacques Riouxby leahcimp,Perfect, thank you!
(My attempt was close... didn't know about the "my" in the second set statement)