Turns out I wrote two such applescripts. There is one which you use by just copying the script text to the clipboard and invoking the script. The other works by first compiling the script to MS Word and opening it in Word, then invoking that script.
The first script will work on fewer script formats. The latter script identifies character/dialogue lines by the paragraph styles Scrivener uses when generating the document, rather than identifying them by the format of the line.
I have added a GRAND TOTAL line to the output of each script for you.
For your safety, these script files (.scpt) can each be opened in Script Editor and examined, so you may assure yourself that they are not accessing unexpected resources or doing anything other than what they should be. --gr
Applescripts included here:
Script Clip Count Per Character.scpt
USE: Copy script text right from Scrivener, then invoke this script.
SKETCH: Script skims the text on the clipboard until it sees a line which starts with “SCENE”. It then starts looking for paragraphs that have a ‘:’ in them, on the assumption such lines are dialogue lines with format characterName : dialogue. Script excludes parentheticals from the word count as you would expect.
Word Count Script Doc Per Character
USE: Compile script to Word. Open result in Word. Invoke this script.
SKETCH: This script works by looking for three kinds of style marks in the paragraph: ‘Character’, ‘Dialogue’ and ‘(Cont.)’. If your script format has character and dialogue on the same line, the script assumes a ‘:’ separates the character name from the dialogue text. Because this script drives Word, it runs notably slower than the other script.
KNOWN ISSUE: For reasons unknown, this script sometimes will register a line of dialogue as if spoken by a separate character. So, for example, the character ALICE will get a large word count, but then there will also be another “ALICE” listed in the totals who gets a small word count from a single line of dialogue somewhere. Why these don’t register as the same character is a mystery. I deemed the script still useful enough in spite of this bug.
NOTE: In order to use this script, you will need once to first open it in Script Editor and change this line <tell application “Word”>, so that it uses your computer’s name for your installation of MS Word. In all likelihood that app is called “Microsoft Word” on your mac.
script per-character word counts.zip (45.0 KB)