1

我正在尝试使用 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*)

不是我想要的。我对applescript很陌生,所以我怀疑一些基本的东西出了问题,但我在网上看到的几个例子似乎做了这样的事情。任何帮助表示赞赏。

更新

可能已经找到答案了。我已经看到提示,与专辑名称不同,无法使用 applescript 直接访问事件名称(对我来说似乎很愚蠢,但这就是我目前发现的)

4

2 回答 2

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命令可以做到这一点。

于 2013-01-13T04:00:39.907 回答
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
于 2013-01-13T16:36:24.550 回答