tell application "System Events"
name of current user
end tell
tell application "System Events"
set answer to name of current user
end tell
tell application "Finder"
delete ((POSIX file "/Users/answer/Desktop/untitled folder"))
end tell
tell application "Finder"
empty the trash
end tell
I want to make a universal code to delete this specific folder but I can't seem to make my variable (=answer) work in the quoted path.
answer
.
delete ((POSIX file "/Users/answer/Desktop/untitled folder"))
Best Answer
The following lines of AppleScript code replaces all of the code in your OP:
Note that this directly deletes
thisFolder
and its contents, bypassing the Trash, so be sure this is what you want before using it!As coded, if
thisFolder
does not exist, thetry
command keeps it from fatally halting execution of the code. In other words, you'll not get an error message and it will continue processing additional code in the script, if any.