Monday, July 4, 2022

#1 2022-03-25 11:10:01 am

SunnyFrinton
Member
Registered: 2012-09-13
Posts: 42

Aliases broken APFS

I have been using an AppleScriptObjC script that creates a Numbers document that inserts a jpg image of a signature and has worked for some time. I recently changed to a new MacBook running Monterey and now the script will no longer compile because of the jpg file as alias.
I understand that Apple has changed to APFS which does not support alias files but I cannot find how to change the script to work. Any help would be gratefully received as I now have no idea how to achieve this. (Sorry couldn't find how to format the script)

property cpSignature : alias “Macintosh HD:Users:Ours:Documents:Cats Protection:Branch Information:Signature Sue.jpg"


tell application "Numbers"
    activate
    set thisDocument to make new document with properties {document template:template "Blank"}
    --
    tell thisDocument
        tell active sheet
            delete every iWork item
            set thisImage to make new image with properties {file:cpSignature, position:{394, 525}, width:90}
        end tell
    end tell
end tell


Filed under: numbers, aliases, APFS

Offline

 

#2 2022-03-25 11:47:41 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2352

Re: Aliases broken APFS

hello,

Your script is not AppleScriptObjC but plain AppleScript. But I will try help you here, anyway. I think, you can fix the problem with coercion  Alias Reference >>> File Reference. Because in the Numbers dictionary is recommended File References for image's files:

Applescript:


-- property cpSignature : choose file of type "public.image"
property cpSignature : alias "Macintosh HD:Users:Ours:Documents:Cats Protection:Branch Information:Signature Sue.jpg"


tell application "Numbers"
   activate
   set thisDocument to make new document with properties {document template:template "Blank"}
   set cpSignature to a reference to file (cpSignature as text) -- Coercion Alias to File Reference
   --
   tell thisDocument
       tell active sheet
           delete every iWork item
           set thisImage to make new image with properties {file:cpSignature, position:{394, 525}, width:90}
       end tell
   end tell
end tell

Last edited by KniazidisR (2022-03-25 11:52:07 am)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2022-03-26 10:40:03 am

SunnyFrinton
Member
Registered: 2012-09-13
Posts: 42

Re: Aliases broken APFS

Thanks for your reply, the lines of code shown are from a longer ApplescriptObjC script compiled with Xcode that failed with the error

"AppleEvents failed to encode extension for /Volumes/Macintosh HD/Users/Ours/Documents/Cats Protection/Branch Information/Signature Sue.jpg, err=No such file or directory/2"

I made the change you suggested but it failed with the error

" Can’t make alias "Macintosh HD:Users:Ours:Documents:Cats Protection:Branch Information:Signature Sue.jpg" into type text. (error -1700)"

Is there anything else I can try?

Offline

 

#4 2022-03-26 02:12:03 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2352

Re: Aliases broken APFS

The error messages you provided hint that you have not spelled the alias correctly. To get the correct alias, run the following code, select an image file, and copy the result:

Applescript:


set cpSignature to (choose file)

Last edited by KniazidisR (2022-03-26 02:14:12 pm)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#5 2022-03-27 07:08:32 am

SunnyFrinton
Member
Registered: 2012-09-13
Posts: 42

Re: Aliases broken APFS

Excellent, now all working as expected but I'm curious as to why a working script failed after updating to Monterey.

The original file path was
"Macintosh HD:Users:Ours:Documents:Cats Protection:Branch Information:Signature Sue.jpg"

but using choose file the file path is now
"Macintosh HD - Data:Users:Ours:Documents:Cats Protection:Branch Information:Signature Sue.jpg"

The "- Data" is this to do with APFS?

Once again, thanks for your help, it's saved my sanity!!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)