Page 1 of 1
AppleScript query path to attachment
Posted: Tue Oct 04, 2016 1:32 am
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!
Re: AppleScript query path to attachment
Posted: Tue Oct 04, 2016 8:57 am
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
Re: AppleScript query path to attachment
Posted: Tue Oct 04, 2016 11:37 am
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.
Re: AppleScript query path to attachment
Posted: Tue Oct 04, 2016 3:10 pm
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
Re: AppleScript query path to attachment
Posted: Tue Oct 04, 2016 5:46 pm
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.