为什么这个任务到 iTunes 的 applescript 有时会失败并显示 -1712
Why does this applescript that tasks to iTunes sometimes fail with -1712
我有一些 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)
对于某些用户,但我不知道为什么
有谁知道为什么,或者我该如何改进我的脚本
首先你应该 close access fileref
在你的第一个 return 之前。否则文本文件可能会保持打开状态。
如果用户的 iTunes 资料库太大并且脚本花费太多时间 运行,则该错误看起来像是超时。您应该使用 with timeout-block:
with timeout of 600 seconds
-- your script here
end timeout
玩得开心,迈克尔/汉堡
我有一些 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)
对于某些用户,但我不知道为什么
有谁知道为什么,或者我该如何改进我的脚本
首先你应该 close access fileref
在你的第一个 return 之前。否则文本文件可能会保持打开状态。
如果用户的 iTunes 资料库太大并且脚本花费太多时间 运行,则该错误看起来像是超时。您应该使用 with timeout-block:
with timeout of 600 seconds
-- your script here
end timeout
玩得开心,迈克尔/汉堡