Applescript 为什么这个应用程序描述iTunes的任务有时会在-1712中失败

Applescript 为什么这个应用程序描述iTunes的任务有时会在-1712中失败,applescript,itunes,Applescript,Itunes,我有一些applescript用于在iTunes控制下创建行业列表并将其写入文件,这是完整的脚本: tell application "iTunes" if (count of every file track of library playlist 1) is equal to 0 then set thePath to (POSIX file "/tmp/songkong_itunes_model.txt") set fileref to open

我有一些applescript用于在iTunes控制下创建行业列表并将其写入文件,这是完整的脚本:

tell application "iTunes"

    if (count of every file track of library playlist 1) is equal to 0 then
        set thePath to (POSIX file "/tmp/songkong_itunes_model.txt")
        set fileref to open for access (thePath) with write permission
        set eof fileref to 0
        return
    end if

    tell every file track of library playlist 1
        script performancekludge
            property tracknames : its name
            property locs : its location
            property persistids : its persistent ID
        end script
    end tell
end tell

set thePath to (POSIX file "/tmp/songkong_itunes_model.txt")
set fileref to open for access (thePath) with write permission
set eof fileref to 0

tell performancekludge
    repeat with i from 1 to length of its tracknames
        try
            set nextline to item i of its tracknames ¬
                & "::" & POSIX path of item i of its locs ¬
                & "::" & item i of its persistids
            write nextline & linefeed as «class utf8» to fileref
        end try
    end repeat
end tell

close access fileref
有时它会给

create_itunes_model.scpt:428:436: execution error: iTunes got an error: AppleEvent timed out. (-1712)
对于一些用户,我不知道为什么

有人知道为什么或者如何改进我的脚本吗?首先,您应该在第一次返回之前关闭access fileref。否则,文本文件可能会保持打开状态

如果用户的iTunes库太大且脚本运行时间太长,则该错误看起来像是超时。您应该使用带超时块的:

with timeout of 600 seconds
    -- your script here
end timeout

祝你玩得开心,迈克尔/汉堡

@SherTerKo好的,谢谢我看到了fileref问题-我会解决的。我想如果iTunes库太大,你可能会有超时的问题,那么如果我没有设置默认超时,默认超时是大于还是小于600秒,也就是说,你的更改是否减少或增加了默认超时。我的脚本必须处理大型库,所以我可以增加超时时间,还是必须以某种方式将脚本处理分成几个部分?当然,标准超时时间大约为120秒。您应该能够将超时设置为您想要的任何值。我记得那些超时设置为两个或更多小时的脚本!2分钟就这些了!,好吧,你可能真的有点问题,我会让一个客户来测试一下,如果它解决了问题,请正确回答并给你奖金