• 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: Photos: apply keyword to multiple selection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Photos: apply keyword to multiple selection


  • Subject: Re: Photos: apply keyword to multiple selection
  • From: Stan Cleveland <email@hidden>
  • Date: Tue, 10 May 2016 09:27:23 -0700

On May 10, 2016, at 08:12 AM, 2551phil <email@hidden> wrote:

Hmm, does anyone know how this might be done?

I see from the dictionary that ‘keywords’ are not r/o, and the wording (“to associate”) suggests they should be writable:

keywords (list of text) : A list of keywords to associate with a media item

However, I’m having difficulty figuring out the syntax. If I get my selection like this:


set myList to {}
tell application id "com.apple.Photos"
repeat with i from 1 to count of selection
set end of myList to filename of item i of (get selection)
end repeat
end tell


What verb/command should I use to add a new keyword like “Wedding” to the keywords list of every item in the entire selection?

Hi Phil,

I started with the code from Michael and tweaked it. The version below does 140 photos in 1-2 seconds. Working in our favor is the fact that Photos won't add duplcate keywords. If a keyword is already associated with a photo, trying to add it a second time does nothing. So there's no need to check if a keyword already exists. Also, the trap for error -1700 will detect if NO keywords are associated.

set newKeywords to {"Wedding"} -- list may contain multiple keywords
tell application id "com.apple.Photos"
set selectedPhotos to selection
repeat with i from 1 to (count selectedPhotos)
tell item i of selectedPhotos
try
set keywords to keywords & newKeywords
on error number -1700 -- photo has no keywords
set keywords to newKeywords
end try
end tell
end repeat
end tell

Enjoy,
Stan C.

 _______________________________________________
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: Photos: apply keyword to multiple selection
      • From: Yvan KOENIG <email@hidden>
References: 
 >Photos: apply keyword to multiple selection (From: 2551phil <email@hidden>)

  • Prev by Date: Re: Photos: apply keyword to multiple selection
  • Next by Date: Re: Photos: apply keyword to multiple selection
  • Previous by thread: Re: Photos: apply keyword to multiple selection
  • Next by thread: Re: Photos: apply keyword to multiple selection
  • Index(es):
    • Date
    • Thread