AppleScript query path to attachment

Users asking other users for AppleScripts that work with Bookends.
Post Reply
mclearc
Posts: 29
Joined: Fri Aug 28, 2015 2:10 am

AppleScript query path to attachment

Post by mclearc »

I was wondering if there is a way to query Bookends concerning the path or location of an attachment for a reference given a UUID number? Maybe something along the lines of return «event ToySRFLD» "$UUID" given string:"?"

If I put "attachment" in the string value I get the title of the entry. But I'd like the full path of the attachment, and sometimes (e.g. when the title contains a colon) the actual name of the attachment differs from the title. In any case, if the info is available in Bookends somewhere it would be great to know. thanks!

Jon
Site Admin
Posts: 8659
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: AppleScript query path to attachment

Post by Jon »

In a format, the symbol

m

will tell Bookends to return the attachment file path. So return ref info using a format consisting only of "m" (if that's all you want).

Jon
Sonny Software

mclearc
Posts: 29
Joined: Fri Aug 28, 2015 2:10 am

Re: AppleScript query path to attachment

Post by mclearc »

Hi Jon,

"m" isn't a field that I can get using "return «event ToySRFLD»" and the Bookends #id in applescript. Is there a different event value I'd use? Or is this just for format editing and not applescript? Thanks.

Jon
Site Admin
Posts: 8659
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: AppleScript query path to attachment

Post by Jon »

Yes, you edit the format, not the AppleScript. Bookends can return results formatted any way you like (in this case, having the attachment pathname).

Jon
Sonny Software

mclearc
Posts: 29
Joined: Fri Aug 28, 2015 2:10 am

Re: AppleScript query path to attachment

Post by mclearc »

Right. Finally got it working. For whatever reason, I had to make sure that the output returns without a newline. For posterity I had to do the following (my bash is pretty bad, sorry):

UUID="{query}"
REFNAME=$(/usr/bin/osascript << EOT
tell application "Bookends"
return «event ToySGUID» "$UUID" given «class RRTF»:"false", string:"attachment"
end tell
EOT)
open "$(echo "$REFNAME"|tr -d '\r')"

to get something that would reliably work. But it does! Thanks.

Post Reply