Page 1 of 1

Applescript: get attachment path?

Posted: Fri Aug 04, 2017 1:06 am
by iandol
Hi Jon, it would be neat if we could get get the attachment path using applescript, i.e. a new event: «event ToySGETA» uniqueID would return the path[s] of any attachments ref:uniqueID had.

Re: Applescript: get attachment path?

Posted: Fri Aug 04, 2017 8:11 am
by Jon
You can do that now. Create a format that outputs either attachment names (h) or file path to attachments (m). Then ask Bookends to return that reference using that format.

Jon
Sonny Software

Re: Applescript: get attachment path?

Posted: Fri Aug 04, 2017 12:35 pm
by iandol
Yes for me that would be fine, I suppose it would be good to be able to write a script others could use without requiring them to also install a new format? This was actually inspired by the OPML script Dave83 wrote, I wanted to add links to the PDF if present and make it so others could use it.

Re: Applescript: get attachment path?

Posted: Fri Aug 04, 2017 3:20 pm
by Jon
The documentation is behind the times -- you can fetch the field "attachments" now and get the names, if that's useful.

To get the full path name without a format will, as you say, require a new AppleEvent.

Jon
Sonny Software

Re: Applescript: get attachment path?

Posted: Fri Aug 04, 2017 9:20 pm
by iandol
OK will give that a go, at least having the names means we can say what, and how many, the attachments are, even if we may not easily get their path. Again, this isn't major, but something to consider for a wishlist for future additions to Bookends very useful applescript support.

While we're on the subject of a wishlist for new applescript events, just in case you missed this post, it would be really nice to be able to create static groups with a set of uniqueIDs.

Re: Applescript: get attachment path?

Posted: Sat Aug 05, 2017 10:43 am
by iandol
Jon wrote:you can fetch the field "attachments" now and get the names,

Code: Select all

set ref_att to «event ToySRFLD» ref_id given string:"attachments"
Hi Jon, I tried this and get the title, not the name of the attachment?

Re: Applescript: get attachment path?

Posted: Sat Aug 05, 2017 11:35 am
by Jon
No, I hadn't see that post. And I'll check out the attachments issue.

Jon
Sonny Software

Re: Applescript: get attachment path?

Posted: Sat Aug 05, 2017 11:56 am
by Jon
An oversight on my part. It will work in the next update.

Jon
Sonny Software

Re: Applescript: get attachment path?

Posted: Sat Aug 05, 2017 5:56 pm
by Jon
iandol wrote:While we're on the subject of a wishlist for new applescript events, just in case you missed this post, it would be really nice to be able to create static groups with a set of uniqueIDs.
Do you know that when you scan a document all of the citations used are in the Hits list (in the order they were found)? So instead of a script, just

1. Scan
2. Make a new group and have the popup menu in the naming dialog set to Add Hits

Jon
Sonny Software

Re: Applescript: get attachment path?

Posted: Sat Aug 05, 2017 11:15 pm
by iandol
Yes, thank you. But as much as I miss the Bookends Format editor (by far best in class!!!), I've switched over my workflow to using Pandoc for all my manuscripts. Pandoc uses citeproc and CSL files to automagically create bibliographies. This means when I output my work from Scrivener, it handles generating the bibliography, plus the many things that Pandoc does (handling LaTeX maths, proper outlining, multiple format support, proper figure markup, cross-referencing, very flexible document level filtering). So from the same raw Scrivener manuscript I can flexibly make a fully formatted Word / LaTeX / ODT document without any extra fussing.

I also have to work with some manuscripts where my Windows collaborators use Endnote. I've made a filter to convert Endnote temp citations to BibTeX keys on the fly (so the source document always remains endnote, but I can still generate a bibliography from my Bookends database via Pandoc, no need to use Endnote! 8) ).

The only downside to my workflow is having to tweak CSL if I want a customised bibliography format, and not being able to have groups of my manuscript refs in Bookends. Hence the wish to be able to create groups programmatically.

Re: Applescript: get attachment path?

Posted: Sun Aug 06, 2017 7:15 am
by Jon
I'll see what I can do.

Jon
Sonny Software