AppleScript: what do you want to see in the Scrivener Suite?

de
derick
Posts: 259
Joined: Mon Aug 11, 2008 9:58 pm

Wed Nov 05, 2008 10:45 pm Post

Another, related application would be to loop through every folder and document within a source folder, and create a corresponding empty folder in a new folder.

e.g. one could start with

Drafts
..intro
..body
....part one
....part two
..conclusion

run the script on it and create a new folder hierarchy with a root folder Cuts

Cuts
..intro
..body
....part one
....part two
..conclusion

Alternatively the actual program flow could be to duplicate the source, then set the text of each document/folder in the target to be blank.

User avatar
gr
Posts: 1592
Joined: Wed Feb 14, 2007 3:57 am
Platform: Mac + iOS
Location: Florida

Thu Nov 06, 2008 2:21 am Post

To accomplish these sorts of tasks in Applescript all that would need to be supplied in the Applescript Suite by the application is the ability to get and set the contents of documents together with the ability to interrogate the binder list and create new folder/docs in it.

From the Suite perspective, this is just to supply language for addressing oneself to the basic scrivener objects--no scrivener-specific functions would yet be involved.

I guess making an app Applescriptable can be hairy, but when Applescriptability comes to Scrivener, the kinds of procedures you are imagining require only basic access to Scrivener objects, it seems pretty well assured they would be possible.

--Greg

de
derick
Posts: 259
Joined: Mon Aug 11, 2008 9:58 pm

Tue Nov 18, 2008 3:03 am Post

Here's another problem I'd like to solve with Applescript. I have a document in which footnotes are currently in the text, with FN: at the start of the paragraph. I'd like to loop through each paragraph in the document, and if it begins with FN:, delete the text FN: and convert the paragraph to a Scrivener footnote.

More food for thought.

de
derick
Posts: 259
Joined: Mon Aug 11, 2008 9:58 pm

Tue Dec 02, 2008 3:45 am Post

And another. I am setting up a project with a series of numbered documents (1.1, 1.2, 2.1, 2.2 etc., representing weeks of term/classes per week) and would love to be able to write a script (which would be more-or-less for x=1 to 15; for y=1 to 2; create a new document with name x,y; end for; end for) to create the documents.

Online
User avatar
AmberV
Posts: 20601
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Tue Dec 02, 2008 4:24 pm Post

derick wrote:And another. I am setting up a project with a series of numbered documents (1.1, 1.2, 2.1, 2.2 etc., representing weeks of term/classes per week) and would love to be able to write a script (which would be more-or-less for x=1 to 15; for y=1 to 2; create a new document with name x,y; end for; end for) to create the documents.


Why not just use the existing counter tokens for that? <$n> will give you your week number and <$sn> the class number. <$sn> is linked to <$n> in that it will count up until the next instance of <$n> and then resets to 1.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

Li
Linda108
Posts: 1
Joined: Fri Dec 05, 2008 1:24 pm

Fri Dec 05, 2008 1:42 pm Post

I want to do something rather simple with AppleScript. At least I thought it was simple until I saw that Scrivener doesn't support AppleScript.

I want to take notes from the web and get them into Scrivener, but with more information saved than a Clipping. And easier and faster than Services.

I want to select some text in the browser and create a new document in Scrivener with the title set to the first few words, the text in the body, all or some part in the synopsis, and the url in the references.

Here is a sample Applescript for OmniWeb and DevonThink doing something similar:

set this_url to address of browser 1
set this_selection to do script "unescape(getSelection())" window browser 1
set this_title to the name of browser 1

tell application "DEVONthink Pro" to create record with {name:this_title, type:txt, URL:this_url, plain text:(this_selection & return & return & this_url)}

So for Scrivener, all I need is to be able to create a document and set the various properties.

Another thing I though of doing with AppleScript:
Go through all the documents or selected documents and if there is no synopsis, set the synopsis to the text or the first few words.

I have a lot of notes and I'd like to organize them using the cork board, but they don't have synopses.

Thanks,
Linda

de
derick
Posts: 259
Joined: Mon Aug 11, 2008 9:58 pm

Tue Dec 09, 2008 12:53 am Post

@Amber - I want the count in the document names in the binder, not in the text itself. The counters don't work there, do they?

de
derick
Posts: 259
Joined: Mon Aug 11, 2008 9:58 pm

Fri Dec 12, 2008 7:20 pm Post

Another task

1) parse a bibliography in Harvard format, e.g.

Barrett, S. R., Stokholm, S., and Burke, J.
2001 The Idea of Power and the Power of Ideas: A Review Essay. American Anthropologist 103(2):468-480.
Barth, F. and others
1969 Ethnic groups and boundaries. : Waveland Press Prospect Heights, Illinois.
Berman, B. J.
1990 Control and Crisis in Colonial Kenya: The Dialectic Of Domination. Athens: Ohio University Press.

(this is fairly easy to do with a text search with regular expressions)

2) put each item in the bibliography into a separate document in Scrivener

3) set each document's synopsis to the first few lines of its text



I have been finding Scrivener, especially the index card view, a great tool for designing course syllabi, where one needs to be able to get an overview of the whole course, tag themes that will reoccur week-to-week, move readings around easily, &c. As I think I said above, opening up Scrivener document attributes and the binder to Applescript would make it possible for users to add bibliographic integration features that would just make it even better for these purposes.

User avatar
KB
Site Admin
Posts: 19178
Joined: Tue Jun 13, 2006 11:23 pm
Platform: Mac
Location: Truro, Cornwall
Contact:

Fri Dec 12, 2008 7:35 pm Post

Thanks for all the feedback.

Just for the record, it's highly unlikely that Scrivener will be getting AppleScript support any time soon. It's a big job and low down on the list - certainly it won't be making 1.5. It is still slated for a distant future release, though!

Thanks and all the best,
Keith

User avatar
p a t r i c k
Posts: 61
Joined: Fri Nov 14, 2008 11:30 am
Location: Brighton & Hove, UK
Contact:

Sat Dec 13, 2008 6:42 pm Post

KB wrote:It is still slated for a distant future release, though!


I do find Scrivener to be most excellent indeed. It is great that the programmer is so helpful and responsive on these forums. I know that I would find the endless requests for this and that to get quite trying :)

However this thread brings me to my biggest single critiscism of Scrivener which is the lack of AppleScript support.

The last project I did almost entirely within Scrivener and so lack of AppleSript wasn't a problem. My next series of projects is going to have a great deal more research materials and for that I will be using DEVONthink and DEVONagent.

The workflow is going to be:

Research: DEVONagent DEVONthink
Writing: Scrivener
Prettyfication of output: Pages

Although I haven't started I already know that using scripts to take selected materials from DEVONthink to Scrivener would be very handy. At present I'm not sure how that is going to work out so it is not possible to answer the basic question of the thread. In a few months I will be able to have useful thoughts about how the ideal Scrivener suite would look for me anyway.

A great thing about AppleScript support is that it is useful to people far beyond those that like to write the scripts themselves. AppleScripts could be uploaded to a "Scrivener AppleScript bank" and downloaded by those who don't script to try out.

Also an AppleScript forum for Scrivener included in this phpBB forum would mean that people who don't script or need help with it could post their questions and there are always many who do like to script who love to answer these things.

I know of course that AppleScript support could not happen by 1.5. However it is looking like 1.5 is going to contain a lot of excellent things :)

de
derick
Posts: 259
Joined: Mon Aug 11, 2008 9:58 pm

Sun Dec 21, 2008 7:48 am Post

Sorry to hear that Applescript support isn't coming soon...looking forward to it whenever it does arrive though.

Patrick - one solution I've found (specifically to the bibliographic task I described above) is to use a scriptable program to create rtfs which can then easily be imported to Scrivener en masse. Specifically, I wrote an Applescript that uses BibDesk and TextEdit to create individual named .rtfs for each reference, which I can then drag into Scrivener to get the same results I described.

Same approach would work with some of the folder creation tasks I described above, actually - write an Applescript for the Finder to set up the folders, then drag these folders into Scrivener.

User avatar
p a t r i c k
Posts: 61
Joined: Fri Nov 14, 2008 11:30 am
Location: Brighton & Hove, UK
Contact:

Sun Dec 21, 2008 11:51 am Post

Hi Derick

I think that is very likely the route I will be taking. I can get DEVONthink to compile an output to RTF then import for example.

The plan for this project which I've now started (while all around me wiser people are munching mince pies) is to keep a total bibliographic database, probably in Bento. In that Bento database then I have a field for all aspects of the Harvard reference style which I'll be using as well as many other aspects of each book. At the end of the project I can output from that to BBEdit very likely to do some RegEx removal of the database artifacts. This will then go straight to Pages to be included in the final document.

The last project I did I used OmniOutliner for keeping bibliographic record then exported that to be included in the Pages final document.

I'm not in the habit of keeping bibliography in Scrivener.

The reason for using Bento for the new project is its size. It will take four years although there are many spin off things to be produced along the way. So, I want a master database which will keep a lot of books and allow me to select those for final bibliography as well as for smaller bibliographies along the way.

dr
druid
Posts: 1721
Joined: Fri Jun 22, 2007 2:29 pm
Platform: Mac, Win + Linux
Location: Princeton NJ, USA

Sun Dec 21, 2008 5:46 pm Post

Patrick,

For a bibliographic database of the type you describe, you need to use either EndNote or BookEnds. The main reason these are useful is the styling of output types, namely your footnotes and bibliographies in either articles or chapters. No matter how much input Bento can accept, I doubt it can give you output in the hundreds of styles available in a bibliographic manager. They will also search library and other online catalogs for you and download selected references, saving you hours of typing. See the numerous references on this forum to bibliography and footnotes for more information.

D.

User avatar
gr
Posts: 1592
Joined: Wed Feb 14, 2007 3:57 am
Platform: Mac + iOS
Location: Florida

Sun Dec 21, 2008 11:54 pm Post

With Endnote, it is also easy to insert with Endnote calls "temporary citations". Later, when you compile your draft from Scrivener, you can take the result into Word and post process with Endnote into any bibliographic style you like -- or Endnote will operate directly on rtf files, too.

You should definitely not do work to create your own customized bibliographic database from scratch. Believe me, I have been there: I had a pretty good solution going long ago before there was an Endnote, but Endnote quickly supplanted my roll-your-own system.

--Greg

P.S. You might want to search these forums for discussion of citations and bibliographic software. If you search for 'Endnote', you should find somewhere a detailed description of how I use Endnote with Scrivener.

User avatar
p a t r i c k
Posts: 61
Joined: Fri Nov 14, 2008 11:30 am
Location: Brighton & Hove, UK
Contact:

Mon Dec 22, 2008 1:16 pm Post

Thanks druid and gr for putting me back in the way of thinking about Endnote :)

In the past when I've checked it out I've always dismissed it for what I was doing but it might be very suitable for my new project(s).

I'm going to check it out again and I'll also be looking at Bookends and Sente.