授予 AppleScript 脚本权限

时间:2021-01-03 16:08:12

标签: applescript

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

DetailView

保存时 AppleScript 返回以下错误:

errormessage

1 个答案:

答案 0 :(得分:1)

您将删除文字字符串 "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