Applescript无法使<list>成为类型说明符-1700错误

时间:2015-08-14 05:12:50

标签: applescript

任何人都可以解释为什么下面的Applescript代码会返回错误:

tell application "Photos"
    set idList to {"v3xzjwPQT0y8a844gLHLHWg", "v3w3twPQT0y%%844gLgf4Wg"}
    set itemList to every media item in application "Photos" where its id is in idList
    log (count of itemList)
end tell

错误是:

error "Photos got an error: Can’t make {\"v3xzjwPQT0y8a844gLHLHWg\", \"v3w3twPQT0y%%844gLgf4Wg\"} into type specifier." number -1700 from {"v3xzjwPQT0y8a844gLHLHWg", "v3w3twPQT0y%%844gLgf4Wg"} to specifier

3 个答案:

答案 0 :(得分:0)

使用OSX 10.9和iPhoto的这行代码没有错误。也许在“照片”/10.10中有些变化?

无论如何,如果你移动代码行,你仍然会得到错误

set idList to {"v3xzjwPQT0y8a844gLHLHWg", "v3w3twPQT0y%%844gLgf4Wg"}

到Tell“Photos”块之前?错误是说“照片”在尝试制作idList时出错。所以尝试在没有Photos的情况下定义idList。我认为可以在不告诉照片的情况下定义列表。

答案 1 :(得分:0)

我有同样的问题。我的目标是获取不在某个相册中的所有图像。 错误在行中上升

set itemList to every media item in application "Photos" where its id is in idList

这种单线也会导致错误

set itemList to every media item in application "Photos" where its name is in {"bla"}

下面的行是有效的

set itemList to every media item in application "Photos" where its name is "bla"

但这不能解决问题。也许有人建议如何做。

答案 2 :(得分:0)

该功能在Photos 4中似乎已损坏。您可以通过两种方法解决该功能。如果您的列表简单且固定,则可以使用or语句来构建命令,如下所示:

set itemList to every media item whose id is "wi9HoFU0SKCDianaQBtJBg" or id is "DT29HF1lRgCKOaIZFHoHrQ"

如果您需要更灵活的功能,则可以使用重复循环并通过单独的搜索来建立列表:

set idList to {"wi9HoFU0SKCDianaQBtJBg", "DT29HF1lRgCKOaIZFHoHrQ"}
tell application "Photos"
    set newList to {}
    repeat with thisID in idList
        set anItem to (first media item whose id is thisID)
        copy anItem to end of newList
    end repeat
end tell