我需要访问关键字的名称属性以在 iPhoto 中选择照片。如何访问keyword
这些照片的元素?我可以访问照片的属性,但不能访问keyword
元素。
我是 Applescript 的新手,所以如果这很无聊,我深表歉意。感谢您的任何帮助,您可以提供。
编辑:这是我尝试过的。
set keywordsRef to a reference to keyword of p --p is a photo
set keyName to name of keywordsRef
我得到错误-1700。不确定这是否有帮助。
编辑2:
tell application "iPhoto"
activate
try
set myPhotos to selection
if myPhotos is false or (the count of myPhotos) is 0 then
error "Please select an image"
end if
repeat with p in myPhotos
set keyname to the name of keyword 1 of p --This works.
set xmldata to xmldata & my addNewPhoto(p) --Try to get keywords here.
end repeat
on error
--display dialog "Error"
end try
end tell
on addNewPhoto(p)
set photodata to "<dict>" & return & my addPhotoName(name of p) --This works.
--set keyname to the name of keyword 1 of p --This gets a syntax error at the "1" after keyword. It expects the end of line.
set keycount to the count of keywords of p
repeat with i from 1 to keycount
--log (the name of keyword i of p as string) --Syntax error also at "i" after keyword.
end repeat
set photodata to photodata & my addPhotoKeywords()
set photodata to photodata & "</dict>" & return
end addNewPhoto