• 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: Removing iPhoto 08 Keywords with Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing iPhoto 08 Keywords with Applescript


  • Subject: Re: Removing iPhoto 08 Keywords with Applescript
  • From: "Mark J. Reed" <email@hidden>
  • Date: Sat, 21 Mar 2009 09:02:01 -0400

Well, since you can't manage iPhoto's keyword set without GUI
scripting, why not remove the tags that don't exist in iPhoto from the
image file before importing?  You can use exiftool to do that... this
works OMM.  (If there's a better idiom for "only those items in listA
that exist in listB" than looping through, let me know...):

tell application "iPhoto"
	set validKeywords to name of every keyword
end tell

set importFolder to choose folder with prompt "Choose import folder"

tell application "Finder"
	set photoFiles to (every file of importFolder whose name extension is
in {"jpg", "JPG"}) as alias list
end tell

repeat with aPhoto in photoFiles
	set incomingKeywords to getKeywords(aPhoto)
	set recognizedKeywords to {}
	repeat with aKeyword in incomingKeywords
		if aKeyword is in validKeywords then
			set end of recognizedKeywords to aKeyword as text
		end if
	end repeat
	setKeywords(aPhoto, recognizedKeywords)
end repeat

on getKeywords(someFile)
	set text item delimiters to ","
	do shell script ¬
		"exiftool -s -s -s -sep , -keywords " & (quoted form of POSIX path
of someFile)
	return text items of result
end getKeywords

on setKeywords(someFile, keywordList)
	set text item delimiters to ","
	do shell script ¬
		"exiftool -s -s -s -sep , -keywords=" & (quoted form of (keywordList
as text)) & " " & (quoted form of POSIX path of someFile)
end setKeywords

--
Mark J. Reed <email@hidden>
 _______________________________________________
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: Removing iPhoto 08 Keywords with Applescript
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Removing iPhoto 08 Keywords with Applescript (From: Chris Glowacki <email@hidden>)
 >Re: Removing iPhoto 08 Keywords with Applescript (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Can someone explain this?
  • Next by Date: Re: Removing iPhoto 08 Keywords with Applescript
  • Previous by thread: Re: Removing iPhoto 08 Keywords with Applescript
  • Next by thread: Re: Removing iPhoto 08 Keywords with Applescript
  • Index(es):
    • Date
    • Thread