I wrote a script to be run as a service that would import selected photos from Finder into a chosen iCloud album (My PhotoStream, Shared). The script completes successfully but the imported photos show up in Events and not iCloud section of the app. Also, when selecting “Get Info” it has indication that the photos were indeed imported to a shared album – I see the sharing status bar-indicator reading that “was published n minutes ago”. There’re 2 issues: (1) I don’t see them on my iPhone with everything on and enabled of course (2) As soon as I go to “iCloud” section’s shared destination album on the Mac I see those photos briefly flashing before they disappear for good.
My question: is it possible to script import in these applications at all without having to plug Finder scripting and other overly complex workarounds?
tell application "Finder"
set AliasRefs to selection as alias list
tell application "System Events"
set UTIs to {}
repeat with i from 1 to number of items in AliasRefs
set this_item to item i of AliasRefs
if type identifier of this_item is in {"public.png", "public.jpeg"} then set end of UTIs to type identifier of this_item
end repeat
if UTIs is {} then
display alert "No images were selected!" message "Select image files and run the service again." as informational buttons {"OK"} default button 1 giving up after 3
return
end if
set PosixRefs to {}
repeat with i from 1 to number of items in AliasRefs
set this_item to item i of AliasRefs
set end of PosixRefs to POSIX path of this_item
end repeat
end tell
end tell
tell application "iPhoto"
set SharedAlbumNames to get name of every album whose url is not ""
set SharedAlbums to get every album whose url is not ""
set Prompt2ChooseAlbum to choose from list SharedAlbumNames with prompt "Choose an iCloud album" with title "iCloud albums" default items {item 1 of SharedAlbumNames} without multiple selections allowed --this is a list
if Prompt2ChooseAlbum is false then
error number -128
else
set TargetAlbumName to the first item of Prompt2ChooseAlbum --get name of the album to import to
try
repeat with i from 1 to the number of items in SharedAlbums
set theAlbum to item i of SharedAlbums
if name of theAlbum is TargetAlbumName then
repeat with j from 1 to the number of items in PosixRefs
set ImagePath to item j of PosixRefs
import from ImagePath to theAlbum without force copy
end repeat
exit repeat
end if
end repeat
on error
display alert "Importing to the chosen iCloud album failed." as informational buttons {"OK"} default button 1 giving up after 3
end try
end if
end tell
Model: MacBook Pro
AppleScript: 2.3.2
Browser: Safari 9537.86.7
Operating System: macOS 10.9