Skip to main content
Inspiring
March 23, 2015
Answered

Why are Adobe scripting docs like for Illustrator vague on Applescript's file open?

  • March 23, 2015
  • 2 replies
  • 1931 views

From the Adobe scripting reference for Applescript, for Illustrator (I believe is same for other products too), I see code example snippets like:

on openFile(fileToOpen)

    tell application "Adobe Illustrator"

        activate

        open POSIX file fileToOpen as alias with options

    end tell

end openFile

Why does it leave us to figure out the (string) value of fileToOpen? Understandable that that is Applescript specific, but that is more work for those of us not familiar with Applescript to do more research.

Is "as alias" really needed? I'm having trouble with this. Omitting "as alias" gets Applescript error: "Adobe Illustrator got an error: AppleEvent handler failed." Keeping "as alias" results error saying it can't create alias to the path, which for some reason looks like it's formatted as Applescript path even though specified as POSIX (e.g. ":~:Documents:Temp:someFile.ai" instead of "~/Documents/Temp/someFile.ai").

Tried the straightforward example

open POSIX file "~/Documents/Temp/someFile.ai"

as well as

set pfile to "~/Documents/Temp/someFile.ai" as POSIX file

open pfile without options

set pfilepath to "~/Documents/Temp/someFile.ai"

set pfile to POSIX file pfilepath

open pfile as alias without options

nothing seems to work so far. Such a pain.

This topic has been closed for replies.
Correct answer CarlosCanto

That's kind of what I mentioned...it needed a file object

2 replies

man9ar00Author
Inspiring
March 26, 2015

Turns out had to do something like this:

set pfilepath to POSIX path of "~/Documents/Temp/test.png"

set pfile to POSIX file pfilepath as text

tell application "Adobe Photoshop CS6"

   activate

   open file pfile without options

end tell

from MacScripter / Pass POSIX file path to Adobe Illustrator to run ExtendScript

Inspiring
March 26, 2015

Thanks for sharing your findings with the community, sadly there is not much happening anymore around here concerning Applescript questions and answers, MacScripter‌ is the go to resource if you have questions for Applescript.

CarlosCanto
Community Expert
Community Expert
March 24, 2015

in javascript, "fileToOpen" expects an actual File Object, not a string.

var file = new File( "C:/Users/carlos/Documents/Illustrator/Forum Questions/missingFontAparatija.ai");

var idoc = app.open(file);

man9ar00Author
Inspiring
March 24, 2015

Thanks, I'll do more research. Unfortunately, it's not very clear in the Adobe Applescript docs. It doesn't appear to be a file object (and not sure if there is file object in Applescript), so it seems more like string there.