首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取iphoto相册的名称

如何获取iphoto相册的名称
EN

Stack Overflow用户
提问于 2013-01-13 01:03:24
回答 2查看 1.4K关注 0票数 1

我正试图用applescript/iphoto获得专辑的名称。到目前为止我已经拿到这个了

代码语言:javascript
复制
tell application "iPhoto"
activate
set theEvents to get every album
repeat with aEvent in theEvents
    log name of aEvent
end repeat
end tell

但当它打印出名字时,我得到了这个:

代码语言:javascript
复制
(*name of album id 6.442450942E+9*)
(*name of album id 6.442450941E+9*)
(*name of album id 6.44245094E+9*)

不完全是我想要的。我对applescript非常陌生,所以我怀疑一些基本的东西出了问题,但是我在网上看到的几个例子似乎都是这样的。任何帮助都很感激。

更新

可能已经找到答案了。我看到了一些暗示,即不可能直接使用applescript访问事件名称,不像专辑名(对我来说似乎很傻,但这正是我目前所发现的)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-13 04:00:39

试试这个:

代码语言:javascript
复制
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
EN

Stack Overflow用户

发布于 2013-01-13 16:36:24

答案之一,已经被接受了,但我想把这个张贴给未来的读者。

代码语言:javascript
复制
    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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14299624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档