So there goes four hours of my life that I will never get back.
I'm trying to do something seemingly simple…
I want to open a file select dialog box and specify the default location.
I actually got this to work using the following…
choose file with prompt "Please choose a file:" of type {"XLSX", "APPL"}
default location "/Users/lowken/Dropbox/"
This works and does exactly what I want (the file dialog opens up in the Dropbox folder).
However when I try to use a string variable it doesn't work…
set strPath to "/Users/lowken/Dropbox/"
choose file with prompt "Please choose a file:" of type {"XLSX", "APPL"}
default location strPath
Now the dialog box opens in the root directory of the hard drive 🙁
It seems that the default location is being ignored however if the path is not correct Applescript does raise a error.
I've tried casting the value as a string. I even tried to use the POSIX format…
"Macintosh HD:Users:lowken:Dropbox"
This didn't format didn't work at all.
I'm running OS X Yosemite 10.10.4 on a mid 2012 MacBook Pro.
Can anyone help me?
Best Answer
Both scripts don't work for me. The problem is that the
default location
parameter needs to be of typealias
. You can fix it by addingPOSIX file
in front of your path (the path does need to exist, otherwise you also get an error message):Or you could use the "old style" HFS format: