Pass POSIX file path to Adobe Illustrator to run ExtendScript

Here’s the code snippet I started with

tell application "Adobe Illustrator"
    delay 10
    set pfilepath to "/Users/username/Documents/Temp/"
    set pfile to POSIX file pfilepath
    open pfile as alias without options
    delay 10
    do javascript "#include '/Users/username/Documents/Temp/someScript.jsx'"
    delay 1
end tell

activate, open, quit, and “do javascript” commands are from/for Adobe Illustrator AppleScript API.

I originally ran the snippet through Python interface to Applescript and that didn’t produce any error statements to debug, so I then executed directly from Applescript editor.

I’m using Mac OS X 10.9.5 with Adobe Illustrator CS6. The Applescript reference for Illustator CS6 should be this:

Does the code & syntax look correct, or what might I be doing wrong? Because the script is not currently working. I get error about can’t get POSIX file. Tweaking code yesterday, with help of someone online in another discussion forum, I get other related errors, but as that discussion got deleted, I don’t recall the exact tweaks and errors, but suffice to say, tweaks didn’t help.

I personally am not familiar with Applescript. I know & prefer Windows COM API.


for one thing this section doesn’t need to be in the tell block:

set pfilepath to "/Users/username/Documents/Temp/"
set pfile to POSIX file pfilepath

delay 10

Edited:wait, no not the open

Edited: don’t mind me. Just anal retentive.


Moved the file path definition outside the tell block as you suggested, didn’t help.

Now, I remember one of the errors seen before that I got now:

note that I switched to testing with Adobe Photoshop CS6 (“tell application Adobe Photoshop CS6”, syntax is a bit different for app name between Illustrator & Photoshop).

The input POSIX path is “~/Documents/Temp/test.png”

Is is really converting path to POSIX or still treating as Mac path?


this is the easy way, no delay needed, it works with Illustrator and Photoshop

set pfilepath to (path to documents folder as text) & "Temp:test.png"
tell application "Adobe Photoshop CS6"
	open file pfilepath without options
end tell

I’ll give that a try StefanK, but what’s that part in parenthesis? Can you clarify it? That tells the script to figure out the path to Documents folder then you define what goes after it, in Mac file path format?

This would work temporarily, but I prefer to use POSIX paths. I’m building a cross platform command line script (in Python) that drives Illustrator & Photoshop. On PC, behind the scenes it uses COM, on Mac, (it will run) Applescript. Frankly using the terminal in Mac along with drag & drop files to terminal, I believe typically defaults to POSIX paths, so I don’t want to deviate from it. Why is POSIX such a pain for Applescript…

path to documents folder is the alias specifier to the folder Documents of the home folder of the current user.

HFS path is the native path representation of AppleScript, that’s just how it is.
If you really want POSIX path, use this

set pfilepath to POSIX path of (path to documents folder) & "Temp/test.png"
set pfile to POSIX file pfilepath as text
tell application "Adobe Photoshop CS6"
	open file pfile without options
end tell

PS: POSIX file returns a file URL. AI and PS aren’t able to recognize this type. The solution is to coerce file URL to text (HFS path)

Thanks for the help. :slight_smile: