With iCloud Photo Library active the scripts will frequently give timeout errors and the selection of photos with (get selection) is not very stable.
Either select the photos only in the "All Photos" album - nearly impossible in a large library or put them into a top level album with a fixed name.
I modified Old Toad's script above, so it can receive the photos in an album name "PhotoDropBox". You can change the name of the album in the script.
I also added error checks. The script will repeat the action after a delay and try again:
-- on run {input, parameters}
(*
batch change the title to the input with capture date and padded numbers, © léonie and Old Toad , version 2.0
The title format is: EXIF Capture Date (System's Short Date)–Description–Padded Sequential Number
Open this script in Script Editor. Launch Photos.
The photos can be passed to the script in two ways:
1. Either select photos while viewing the "All Photos" album; this works better than Moments or smart albums
2. Or collect the Photos in a top level defined album with a fixed name.
If you want to select the photos without collecting them in an album, set the variable "ReadFromAlbum" to false
If you want to pass the photos in a toplevel album, set ReadFromAlbum to true and change the variable "theAlbumName" to the name of the album you are using.
When all all photo are selected or in the album and all parameters set, press the "Run" button in Scripteditor. The script will prompt you for the caption to be added to the photos.
*)
set ReadFromAlbum to true
-- set this to true, if you want to pass the photos in a toplevel album
set theAlbumName to "PhotoDropBox" -- change this to the name of the album you will use
set titleSuffix to text returned of (display dialog "Enter the new description: " default answer "" buttons {"OK"} default button "OK")
set n_digits to 2 -- how many digits for the appended number
set answer to display dialog "Select the number of digits for the appended numbers (0 .. 10). Selecting '0' will suppress the leading zeros." buttons {"o.k"} default answer n_digits
set n_digits_text to the (text returned of answer)
set n_digits to n_digits_text as number
tell application "Photos"
activate
set counter to 1
if (ReadFromAlbum) then -- the photos will be passed in a toplevel album named "PhotoDropBox"
try
if existscontainertheAlbumName then
set thePhotosBuffer to containertheAlbumName
set imageSel to every media item of thePhotosBuffer
else
error "Album " & theAlbumName & "does not exist"
end if
on error errTexttwonumbererrNumtwo
display dialog "Cannot open album: " & errNumtwo & return & errTexttwo
end try
else -- process the selected photos from the All Photos album
try
set imageSel to (get selection)
on error errTexttwonumbererrNumtwo
display dialog "Cannot get the selection: " & errNumtwo & return & errTexttwo
end try
end if
if imageSel is {} then
error "Please select some images."
else
repeat with next_image in imageSel
-- the counter with padded numbers
set ntext to the counter as text
repeat while (the length of ntext < n_digits) -- add leading zeros
set ntext to "0" & ntext
end repeat
-- retrive the date
try
set capture_date to (the date of next_image)
set short_capture_date_string to the short date string of capture_date
-- set capture_time_string to the time string of capture_date
set new_title to short_capture_date_string & "-" & titleSuffix & "-" & ntext as text
tell next_image
set the name to new_title as text
set counter to counter + 1
end tell
on error errTexttwonumbererrNumtwo
display dialog "Error: " & errNum & return & errText & "Trying again"
try
delay 2 -- second try after delay
set capture_date to (the date of next_image)
set short_capture_date_string to the short date string of capture_date
set new_title to short_capture_date_string & "-" & titleSuffix & "-" & ntext as text
tell next_image
set the name to new_title as text
set counter to counter + 1
end tell
display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo
end try
end try
end repeat
end if
end tell
return new_title
-- end run
This version is a stand-alone script, that does not need Automator.
If you want to compile it, uncomment the "on run" and "end run" lines.
It is working well on my larger iCloud Photo Library with 37000 photos right now.