I am trying to write an Apple script to delete all the contents of a folder except one file (stage.txt). This is the script I've written:

tell application "System Events"
    if exists folder "~/Library/Application Support/ABC/CS" then
        delete (every item of folder "~/Library/Application Support/ABC/CS" whose name is not "stage.txt")
    end if
end tell

But I am getting the following error: "System Events got an error: AppleEvent handler failed." number -10000

Please help.

PS: If anyone knows any good tutorial to get started on Apple Script, kindly comment that as well. Thanks!

You must log in to answer this question.

Browse other questions tagged .