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