2013-01-13 42 views
1

我試圖找到與iplescript/iphoto相冊的名稱。到目前爲止,我已經有了這個如何獲得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很陌生,所以我懷疑一些基本的東西出了問題,但我在網上看到的幾個例子似乎是這樣做的。任何幫助讚賞。

UPDATE

可能已經找到答案。我已經看到跡象表明這是不可能直接訪問事件名稱與不同的專輯名稱的AppleScript(似乎愚蠢的我,但是這就是我此刻找到)

回答

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命令執行此操作。

+0

一把槍的兒子。在閱讀了其他一些網站之後,我認爲這是不可能的。非常感謝。 – kdubs

+0

這將返回專輯的名稱,而不是事件的名稱。似乎iPhoto 9.6不會在applescript中公開事件。 – SirVer

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 
+0

謝謝。這是我真正想去的地方。我想循環所有的事件和事件。你可以發佈這樣做的片段嗎? – kdubs

+2

我看了看。您可以將EventAlbum設置爲事件專輯。而且應該能夠做到。 \t將EventEbumAlbumChildren設置爲EventAlbum的子項。但它不會返回任何事件! – markhunte

+0

dang。我希望這會起作用。 – kdubs