Konrad
Konrad

Reputation: 18585

Granting permissions to AppleScript script

I've a simple AppleScript that it's supposed to delete everything in the Downloads folder with exception of selected list of folders passed at the end.

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

On save the AppleScript returns the following error:

errormessage

Upvotes: 0

Views: 134

Answers (1)

vadian
vadian

Reputation: 285039

You are going to delete every item of the literal string "Downloads" which makes no sense. Add the folder specifier

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

or shorter

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

Upvotes: 1

Related Questions