AppleScript API: Missing Hooked Bookmark

Getting the id for a missing linked bookmark (e.g. “hook://file/hJtiIWoYy?p=Lw==&n=(null)”) raises an error:

Error: no such object (e.g. specifier asked for the 3rd, but there are only 2) (errAENoSuchObject:-1728).

The Hook context window handles this gracefully as it can still access the name and path of the missing file (“Cannot locate file x”).

Can anyone suggest how the name and path properties can be accessed using AppleScript so a programmatic solution can be offered? Every method I have tried fails, because the Bookmark id/URL is invalid.

Just to close this; might help someone. I found a way:

The text of an example error message returns: -- "Hook got an error: Can’t get bookmark id \"hook://file/ksd4I5RGl?p=Lw==&n=(null)\"."

Solution is:

  1. Parse the error message for the coded file alias ksd4I5RGl
  2. Search Hook for the matching bookmark set _result to (every bookmark whose address contains ksd4I5RGl)
  3. Get data for missing hooked bookmark from there