Copy link to clipboard
Copied
Beginning with Illustrator 2020, the document object's file path property is returned in POSIX format. Previously, it was in HFS format with the POSIX path property returning the POSIX path. I suspect this is a bug, but thought I'd pass it on since scripts will need to be revised because of it.
For example:
set thePath to ""
tell application "Adobe Illustrator"
tell current document to set thePath to file path as text
end tell
tell application "Finder"
set theFile to file thePath -- this worked before AI 2020, but won't work now with a POSIX path
set theFile to POSIX file thePath -- this won't work with thePath as a variable
set theFile to file ((POSIX file thePath) as string) -- do this instead
end tell
“Beginning with Illustrator 2020, the document object's file path property is returned in POSIX format. Previously, it was in HFS format with the POSIX path property returning the POSIX path.”
This is not quite correct. Pre-2020, the `file path` property contained a ‘file’ value (an Apple event descriptor of typeFSRef). The Carbon File Manager (of which the FSRef type is part) has been deprecated since 10.8 and doesn’t work properly with APFS volumes; hence the update.
Unfortunately, 2020 has ch
...Copy link to clipboard
Copied
I don't do appleScript but thanks for sharing Rick
Copy link to clipboard
Copied
Hi I don't know if this will solve your problem, but I have a script that recently stopped working when upgrading to Illustrator 2020. The fix was to enable AUTOMATION in system prefs>Security & Privacy for your script file.
Copy link to clipboard
Copied
Thanks for the Automation tip. I've never worked with this before, but I see everything I need there is already enabled.
The problem is that Illustrator via AppleScript now sends the current file path in a different format. Also...
==> If a directory in the path contains a slash "/" in its name, Illustrator returns no path string at all.
Slashes and colons in file or directory names have long been problematic, but until now Illustrator has dealt with them quite gracefully.
Copy link to clipboard
Copied
“Beginning with Illustrator 2020, the document object's file path property is returned in POSIX format. Previously, it was in HFS format with the POSIX path property returning the POSIX path.”
This is not quite correct. Pre-2020, the `file path` property contained a ‘file’ value (an Apple event descriptor of typeFSRef). The Carbon File Manager (of which the FSRef type is part) has been deprecated since 10.8 and doesn’t work properly with APFS volumes; hence the update.
Unfortunately, 2020 has changed it from a ‘file’ value to a ‘text’ value (typically an Apple event descriptor of typeUnicodeText), and these two data types are not interchangeable in AppleScript, which means all existing scripts that use this property will break.
What 2020 should have changed it to is a ‘file’ value of typeFileURL, which is the modern successor to the old typeFSS/typeFSRef types. That is, use `[NSURL fileURLWithPath: posixPathString].absoluteString.UTF8String` (or its CoreFoundation equivalent) to convert the file path to a file URL, then pack that into a descriptor of typeFileURL. That will minimize/avoid breaking user scripts as AppleScript treats all ‘file’ types as interchangeable.
In addition, if the document has not yet been saved to disk, right now the result is a string containing a slash followed by the document name, e.g. "/Untitled-1", which is definitely a bug. Instead, it should return ‘missing value’ (an AEDesc of typeType with cMissingValue as its data).
If you search through the app’s dictionary you’ll find other properties and parameters that may also have changed; e.g. the `file path` property of the `placed item` class, the `action file path` of the `load action` command. You might want to write some tests to see if that’s the case.
Feel free to include the above information when filing a bug report with Adobe. No guarantees they’ll be able/willing to make a quick compatibility fix for 24.0.1, but even if they do decide to leave it as a POSIX path string they need to fix the result when no file exists.
--
[edited to add] Until/Unless this is fixed in AI, if you need to write portable scripts then this will work (assuming the file exists; if not, AI returns garbage anyway):
to normalizeFilePath(v) -- given POSIX path or file value, returns a file value
if class of v is text then -- assume v is a POSIX path string
if v does not start with "/" then -- sanity check
error "Not a POSIX path string." number -1700 from v to «class furl»
end if
return POSIX file v
else -- assume v is some type of 'file' value
return v as «class furl»
end if
end normalizeFilePath
tell application "/Applications/Adobe Illustrator CC 2019/Adobe Illustrator.app"
set f to my normalizeFilePath(file path of document 1)
end tell
log f --> file "Macintosh HD:Users:has:test.ai"
tell application "/Applications/Adobe Illustrator 2020/Adobe Illustrator.app"
set f to my normalizeFilePath(file path of document 1)
end tell
log f --> file "Macintosh HD:Users:has:test.ai"