我的脚本用户通过AppleScript与iPhoto进行通信时收到此错误,我无法重现:918:955: execution error: iPhoto got an error: "4.294967323E+9Mahabalipuram" doesn’t understand the “write” message. (-1708)
产生错误的AppleScript是:
set nul to character id 0
set text item delimiters to nul
set albumsFile to "/Users/[user]/Downloads/blah.blah"
set fp to open for access (POSIX file albumsFile) with write permission
tell application "iPhoto"
repeat with anAlbum in albums
if anAlbum's type is regular album then
set albumName to anAlbum's name
if albumName is not "Last Import" then
set albumPhotoIds to (id of every photo of anAlbum) as Unicode text
if length of albumPhotoIds is greater than 0 then
set currentAlbum to anAlbum
repeat while currentAlbum's parent exists
set currentAlbum to currentAlbum's parent
set albumName to currentAlbum's name & " > " & albumName
end repeat
set albumId to anAlbum's id
set albumData to {"", albumId, albumName, ""} as Unicode text
write albumData to fp as Unicode text
write albumPhotoIds to fp as Unicode text
write nul to fp as Unicode text
end if
end if
end if
end repeat
end tell
close access fp
有没有人对这里出了什么问题有任何想法?这个Github问题有更多背景知识:https://github.com/jawj/iphoto-flickr/issues/7
答案 0 :(得分:1)
这可能有用(未经测试);它通常会出现这种错误。但是,正如adayzone指出的那样,最好重新构建脚本。
tell me to write albumData to fp as Unicode text
tell me to write albumPhotoIds to fp as Unicode text
tell me to write nul to fp as Unicode text
说明告诉如何工作(有时“妨碍”)也很好。
答案 1 :(得分:0)
写入来自StandardAdditions,而不是iPhoto,因此您无法告诉iPhoto写入。这将是:
property nul : character id 0
set text item delimiters to nul
set albumsFile to (path to downloads folder as text) & "blah.txt"
tell application "iPhoto"
repeat with anAlbum in albums
if anAlbum's type is regular album then
set albumName to anAlbum's name
if albumName is not "Last Import" then
set albumPhotoIds to (id of every photo of anAlbum)
if length of albumPhotoIds is greater than 0 then
set currentAlbum to anAlbum
repeat while currentAlbum's parent exists
set currentAlbum to currentAlbum's parent
set albumName to currentAlbum's name & " > " & albumName
end repeat
set albumId to anAlbum's id
set albumData to {"", albumId, albumName, ""} as Unicode text
my writeIt(albumsFile, albumData, albumPhotoIds)
end if
end if
end if
end repeat
end tell
on writeIt(albums_File, album_Data, album_PhotoIds)
try
set fp to open for access albums_File with write permission
write album_Data to fp
write album_PhotoIds to fp
write nul to fp
close access fp
on error
try
close access fp
end try
end try
end writeIt