AppleScript: when concatenating a POSIX path a comma is inserted?

77 Views Asked by At

I have this code

tell application "Finder" of machine "eppc://[email protected]"
    open POSIX file "/Volumes/tmp/" & fileName
end tell

but when I execute it I get an error and log looks like this:

tell application "Finder" of machine "eppc://air.local"
    open {file "Macintosh HD:Volumes:tmp:", "myfile 1:1.txt"}
        --> error number -10010
end tell

Why?

The file is there but I wonder about the Macintosh HD part of the path. The volume is named that but in a POSIX path you start with /, not Macintosh HD, don't you? Also, I wonder about the "broken up" file path "Macintosh HD:Volumes:tmp:", "myfile 1:1.txt" - this doesn't look right?

(tmp is remote volume so it is correct that it is mounted under /Volumes/)

Note that the filename contains a colon.

1

There are 1 best solutions below

3
Robert Kniazidis On

You need coercion as Posix file instead of specifier.

tell application "Finder" of machine "eppc://[email protected]"
    open ("/Volumes/tmp/" & filename) as POSIX file
end tell

Or, move the specifier out of Finder tell block:

set filename to "160094_full.jpeg"
set posixFile to POSIX file ("/Volumes/tmp/" & filename)

tell application "Finder" of machine "eppc://[email protected]"
    open posixFile 
end tell

The fact is that this specifier is a concept of a script, not a Finder application. This leads to the 3rd possible solution --- using the me keyword:

set filename to "160094_full.jpeg"

tell application "Finder" of machine "eppc://[email protected]"
    open (POSIX file ("/Volumes/tmp/" & filename) of me)
end tell