Re: Removing iPhoto 08 Keywords with Applescript
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