I have a line of script as follows:
set Imagepath to POSIX file thePath as alias
When thePath points to a file in my user folder, the above returns the correct alias so I can open the file.
When thePath points to
… the script returns the following error:
Is there a way around this? I just want to open the file in Photoshop…
Thanks
The path has spaces in it that you should escape or use quoted form of…
This works for me:
set tPath to "/private/tmp/"
set F to (POSIX file tPath) as alias
Not for you? Are you an admin user?
My fault. The tmp directory did not exist. If I have a path to a file in thePath, how can I test if the file referenced by thePath exists, before forcing the alias?
set tPath to "/private/tmp/"
try
set F to (POSIX file tPath) as alias
on error
do shell script "mkdir /private/tmp"
set F to (POSIX file tPath) as alias
end try
Thanks for the help, have included this to check for file before forcing alias:
set msg to false
tell application "Finder" to if exists thePath as POSIX file then set msg to true
If msg is true, I can force an alias. Otherwise, the script generates an error.