授予对 AppleScript 脚本的权限

Granting permissions to AppleScript script

我有一个简单的 AppleScript,它应该删除 Downloads 文件夹中的所有内容,最后传递的选定文件夹列表除外。

tell application "Finder"
    delete (every item of "Downloads" of folder currentUser of folder "Users" of startup disk whose name is not in {"PreciousFolder"})
end tell

保存 AppleScript returns 出现以下错误:

您将删除没有意义的文字字符串 "Downloads" 中的每一项。添加 folder 说明符

tell application "Finder"
    delete (every item of folder "Downloads" of folder currentUser of folder "Users" of startup disk whose name is not in {"PreciousFolder"})
end tell

或更短

tell application "Finder"
    delete (every item of (path to downloads folder) whose name is not in {"PreciousFolder"})
end tell