AppleScript没有权限保存文件

时间:2015-07-24 19:50:54

标签: permissions applescript

使用Applescript将文件写入外部硬盘时,会显示以下错误: The document “Untitled 2” could not be exported as “test.txt”. You don’t have permission. 我的代码应该使用TextEdit编写一个文件,并将其保存为.txt文件。我的代码:

tell application "TextEdit"
activate
make new document
set theDate to current date
set text of document 1 to do shell script "curl 'www.google.com'"
tell application "System Events" to tell process "TextEdit"
    if menu item "Make Plain Text" of menu 1 of menu bar item "Format" of menu bar 1 exists then
        keystroke "t" using {shift down, command down}
        keystroke return
    end if
end tell
save document 1 in "HARDRIVE:test.txt"
end tell

(HARDRIVE是我的外置硬盘)。 为什么会导致此错误?我该怎么做才能解决它?

由于

1 个答案:

答案 0 :(得分:2)

使用文件对象作为路径 - > 文件“某些HFS路径”

save document 1 in file "HARDRIVE:test.txt"