我正试图用applescript / iphoto来获取专辑的名称。到目前为止我已经有了这个
tell application "iPhoto"
activate
set theEvents to get every album
repeat with aEvent in theEvents
log name of aEvent
end repeat
end tell
但是当它打印出我得到的名字时:
(*name of album id 6.442450942E+9*)
(*name of album id 6.442450941E+9*)
(*name of album id 6.44245094E+9*)
不是我想要的。我对applecript很新,所以我怀疑基本出错了,但我在网上看到的几个例子似乎都是这样的。任何帮助表示感谢。
更新
可能已找到答案。我已经看到提示,不可能直接访问带有Applecript的事件名称而不像专辑名称(对我来说似乎很傻,但这就是我目前所发现的)
答案 0 :(得分:1)
试试这个:
tell application "iPhoto"
activate
set theEvents to get every album
repeat with aEvent in theEvents
log (get name of aEvent)
end repeat
end tell
log
命令不会隐式取消引用您传递的对象说明符。添加get
命令可以做到这一点。
答案 1 :(得分:1)
答案#1已被接受,但我想将此发布给未来的读者。
tell application "iPhoto" to set theEvents to get name of every album
#You can then use the theEvents list.
#Example - log items of theEvents
log theEvents
--> {"Events", "Faces", "Places", "Photos", "Last 12 Months", "Last Import", "Flagged","Trash", "My Photo Stream", "Holiday 2008", "Holiday Sep 2008"}
#Example - work though the items of theEvents with a repeat loop
repeat with i from 1 to number of items in theEvents
set this_item to item i of theEvents
if this_item contains "Holiday" then
log this_item
-->(*Holiday 2008*)
-->(*Holiday Sep 2008*)
end if
end repeat