• 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: Yvan KOENIG <email@hidden>
  • Date: Tue, 10 May 2016 19:08:11 +0200

Hello Stan

You may fasten a bit your script if you drop the use of an index in the loop.

set newKeywords to {"Wedding"} -- list may contain multiple keywords
tell application id "com.apple.Photos"
set selectedPhotos to selection
repeat with aPhoto in selectedPhotos
tell aPhoto
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

Behave flawlessly.

This alternate version works well too.

set newKeywords to {"Wedding"} -- list may contain multiple keywords
tell application id "com.apple.Photos"
set selectedPhotos to selection
repeat with aPhoto in selectedPhotos
tell aPhoto
if its keywords is missing value then
set keywords to newKeywords
else
set keywords to keywords & newKeywords
end if
end tell
end repeat
end tell

I'm not sure of which one is the faster.

Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) mardi 10 mai 2016 19:02:35



 _______________________________________________
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

References: 
 >Photos: apply keyword to multiple selection (From: 2551phil <email@hidden>)
 >Re: Photos: apply keyword to multiple selection (From: Stan Cleveland <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