Reputation: 2835
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?
Upvotes: 0
Views: 1944
Reputation: 285200
default location
of choose file
expects an alias specifier rather than a POSIX path. This is a user and startup disk name independent solution
set dropboxFolder to (path to home folder as text) & "Dropbox"
choose file with prompt "Please choose a file:" of type {"XLSX", "APPL"} default location alias dropboxFolder
Upvotes: 1