Emulate "Go to Dekstop/Home/etc." behavior in OS X via AppleScript
- by pattulus
OS X has build in support for going to certain Folders (Home, Utilities, Desktop, etc.) via a Shortcut.
I wanted to emulate this behavior for the the Downloads Folder. The only thing that is missing the script below is that it won’t succeed when no window is opened in the Finder (see Error message).
tell application "Finder"
activate
set target of Finder window 1 to folder "Downloads" of folder "username" of disk "Macintosh HD"
end tell
Error message:
error "Finder got an error: Can’t set
Finder window 1 to folder
\"Downloads\" of folder \"username\"
of disk \"Macintosh HD\"." number
-10006 from Finder window 1
It great if you know about some kind of 'if-compliement' that triggers opening the Downloads Folder in case there is no window 1 open in the Finder. Thanks in advance.