OSX 10.13.6, AI 2020, Applescript Editor Version 2.10 (194), AppleScript 2.7
(Don’t think this should matter, but am not prepared to upgrade the OS, as NVidia still hasn’t released drivers for the TitanXP GPU the system uses).
Sticking to AppleScript in this discussion. No “Just Use JavaScript” suggestions please, unless you can confirm or deny that the problem also occurs in JavaScript.
Am wondering if Adobe has made a change to their Illustrator API, as, since upgrading to the new 2020 version, Applescript files that used to work with earlier versions of Illustrator are now having difficulty opening files when referred to by an alias, or a variable in posix-style format.
InDesign does not seem to have been affected, as every time a major version upgrade occurs I run a script on some several hundred .INDD files to prevent the “save-as” dialog next time they are used, which can mess up scripting. That script still works. Haven’t tried Photoshop yet, but most of the automation I use there is in the form of their internal “Actions”.
After a little research, am thinking they may have tinkered with HFS support, resulting in unanticipated consequences.
Illustrator 2020 can open a file referenced by a hard-coded string in posix-style format, but it cannot open that same file from a variable, either an HFS-style alias, or quoted posix-style string, i.e,
set theHFSPath to "Mac HD:Users:Mac User:Documents:Illustrator:myFile.ai"
set thePosixPath to quoted form of theHFSPath
# i.e., '/Volumes/Mac HD/Users/Mac User/Documents/Illustrator/myFile.ai'
Tell Application "Adobe Ilustrator"
# Opens OK
open POSIX file "/Volumes/Mac HD/Users/Mac User/Documents/Illustrator/myFile.ai" without dialogs
# Crashes with "Adobe Illustrator got an error: The specified file could not be opened because it could not be found"
open theHFSPath as alias without dialogs
# open (theHFSPath as alias) also crashes
# Crashes with "Adobe Illustrator got an error: File/Folder expected"
open POSIX file thePosixPath without dialogs
# open POSIX file (quoted form of thePosixPath)
# without quoting HFSPath above also crashes
End Tell
Am suspecting Adobe maybe dropped a low-level routine that dealt with HFS, and with this routine failing, the open command cannot “see” the file to open it.
Not much on the ‘tubes yet, but I have run across:
http://forum.latenightsw.com/t/apple-script-for-illustrator-2020-javascript-code-was-missing/2167
from a little less than a week ago, which seems to be describing the same issue.
Anyone else run across this, or know how to get around it?
2
Answers
'k, the issue does not seem to be with regards to HFS or POSIX paths, per se. I very much appreciate all the replies and comments, and still believe there is a bug in AI 2020's open command; will be heading over to Adobe to see if anyone else has reported it.
It was very confusing that if one hard-coded the path, i.e.,
it would work.
However, turns out that with AI 2020, the culprit is the optional "without dialogs" parameter in conjunction with an alias or POSIX-style variable reference to the file.
According to the dictionary one would append
to the open command in order to bypass any regular dialogs AI might present when opening the file.
Though this worked fine in AI 2019, it is causing the open command to crash in AI 2020, even though the AI 2020 dictionary still shows "dialogs" as an optional boolean parameter with the same syntax as the 2019 version.
To test this hypothesis, I cranked up an older Mini that still has AI 2019 on it, and tried:
As expected, this worked just fine, as it has for years.
In AI 2020, with the same file reference,
crashes the open command.
Remove
without dialogs
and it opens as expected.So, the only work-around for now seems to be ignoring the dialogs parameter.
Hopefully Adobe will either update their AS dictionary or fix the bug.
Take care!
The following examples work exactly as expected on AI 2020 (which I’ve just installed) and CC 2017 running under macOS 10.14.6:
This works as expected too (notwithstanding the awful quality of AI’s error messages):
..
However, the following does not work as you’d expect:
The
open
command neither opens the file nor sends back an error message explaining why not. This is one of those maddenly quirky and unintuitive gotchas with AppleScript’s object specifiers, made doubly confusing by AI’s lousy error handling.Short explanation: The script is effectively telling AI to open
POSIX file "…" of <Illustrator>
, and since the app’s dictionary doesn’t include aPOSIX file
class, the app is unable to resolve that reference. Whereas what you need is to first sayPOSIX file "…" of <AppleScript>
, which tells AS to build aPOSIX file
value (which it knows how to do) and then pass the constructed value to theopen
command.This is why it’s always a good idea to build
alias
,POSIX file
,date
, etc values outside of anytell app…
blocks. It’s a crude rule of thumb, but easy to remember. (Best not to think about AS behaviour too hard as you’ll only make your head hurt.)—
Now, if you’re seeing different behaviors under macOS 10.15 then that implies something else has changed (presumably in the OS) which is causing knock-on effects elsewhere; if that’s the case, update your original post with more details.
[updated to add]
These work correctly on AI 2020 and earlier (macOS 10.14.6):
This also works correctly on AI 2020:
However, while these work correctly on AI 2019, on AI 2020 they incorrectly throw a File Not Found error even though the file exists:
Therefore, can confirm there is a [non-crashing] BUG in AI 2020’s
open
command that causes it to fail when its direct parameter is an alias value and one or more positional parameters are also given.For now, you’ll need to work around this bug by coercing your alias value to a
POSIX file
value[1] prior to passing it to AI 2020’sopen
command:Alternatively, it may be a good time rework your AppleScript code to eliminate using alias values and use POSIX file values throughout. The ancient (pre-OSX)
alias
value type has long been deprecated throughout the rest of macOS in favor of modern security-scoped bookmarks, which may be why it’s suddenly breaking in a freshly-updated app like AI 2020.Alas, AppleScript was relegated to maintenance mode some years ago so I doubt Apple will ever sort out its absolute mess of old/new/working/broken file types; they’re just something you’ll need to be aware of and work around in your own code. (i.e. Don’t bother filing an AppleScript feature request with Apple; unless it’s a security hole they’ll likely just ignore it.)
You can if you want file an Adobe bug report on AI 2020’s
open
command. No guarantees they’ll fix it; they may just tell you the same thing—stop passing it [deprecated] alias values and use [supported] POSIX file values instead—but at least it’ll be on the record as WontFix and users can be made aware of it.—
[1] Note that when coercing a value to POSIX file you must write
f as «class furl»
, notf as POSIX file
. This is due to a longstanding defect in AS which Apple are never going to fix.