• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scriplting the Photos application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scriplting the Photos application


  • Subject: Re: Scriplting the Photos application
  • From: Shane Stanley <email@hidden>
  • Date: Sun, 19 Apr 2015 22:32:01 +1000

On 19 Apr 2015, at 9:54 pm, Bill Cheeseman <email@hidden> wrote:

The first thing I tried was almost every single individual property, and I got the same error with all of them.

Hmmm. This probably won't work for you either. It imports photos, and arranges them as albums similarly to the way converted collections are arranged:

set enventsFolderName to "Pseudo Events" -- the name you want your "events" folder to have; change to suit

tell application id "com.apple.Photos" -- Photos
-- choose the picture files to import
set theFiles to choose file with prompt "Choose the pictures to import:" with multiple selections allowed
-- get the name for the new event album
set newName to text returned of (display dialog "Enter a name for the new event album:" default answer "")
-- check the events folder exists, and if not, create it
if exists container enventsFolderName then
set eventsFolder to container enventsFolderName
-- check the event album name is unique
if exists container newName of container enventsFolderName then
display dialog "That name is already in use" buttons {"Cancel"}
error number -128
end if
else
set eventsFolder to make new folder named enventsFolderName
end if
-- make the new event album inside the events folder
set theAlbum to make new album named newName at eventsFolder
-- sort the files by creation date
tell application "Finder"
set theFiles to (sort theFiles by creation date)
repeat with i from 1 to count of theFiles
set item i of theFiles to item i of theFiles as alias
end repeat
end tell
-- import the files
import theFiles into theAlbum
-- rename them after the event album name, plus a digit
set theItems to media items of theAlbum
repeat with i from 1 to count of theItems
-- this part is a bit icky; sometimes naming fails because there's a delay, so we keep trying until it succeeds
repeat
try
set thisPic to item i of theItems
set name of thisPic to newName & "-" & i
exit repeat -- success
end try
end repeat
end repeat
-- all clear
display dialog "Import finished" buttons {"OK"} default button "OK"
end tell

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Scriplting the Photos application
      • From: 2551 <email@hidden>
References: 
 >Scriplting the Photos application (From: Bill Cheeseman <email@hidden>)
 >Re: Scriplting the Photos application (From: Shane Stanley <email@hidden>)
 >Re: Scriplting the Photos application (From: Bill Cheeseman <email@hidden>)
 >Re: Scriplting the Photos application (From: 2551 <email@hidden>)
 >Re: Scriplting the Photos application (From: Shane Stanley <email@hidden>)
 >Re: Scriplting the Photos application (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: Scriplting the Photos application
  • Next by Date: Re: sqlite question
  • Previous by thread: Re: Scriplting the Photos application
  • Next by thread: Re: Scriplting the Photos application
  • Index(es):
    • Date
    • Thread