Copy link to clipboard
Copied
I left the following comment on a Youtube tutorial explaining how to execute a word count query for an Indesign document ASSUMING your article layout uses a single box of text:
What if an article uses a creative layout with multiple text-boxes? Are you supposed to get out your pocket calculator and add them up one-by-one?
I work for a magazine that publishes short, submission-style testimonials bridged together with staff-generated narrative copy; some of our articles use six or more discreet text-boxes. You REALLY MEAN TO TELL ME that there is NO WAY to yield a TOTAL DOCUMENT WORD COUNT using what is SUPPOSED TO BE the MOST ADVANCED page layout application ON EARTH??
Pardon my exasperation in the above comment, but....Seriously?
I need someone knowledgeable to please look me in the eyes and tell me, "This is true", before I am going to be able to let myself believe it.
Thank you.
- Exasperated Journalist Slag
Copy link to clipboard
Copied
Yeah, out of the box that would be true. But I'm sure it's possible to script a total count. Be careful what you are asking, though. Total count would include headers and footers and page folios unless you can design a way to ignore them.
Copy link to clipboard
Copied
Total count would include headers and footers and page folios unless you can design a way to ignore them
If the folios/headers are master page items my script wouldn't include them. You could also skip stories with less than a designated number of words like this, which skips stories with less than 10 words:
tell application "Adobe InDesign CS6"
tell active document
set s to every story
set t to 0
repeat with i from 1 to count of s
if (count every word of item i of s) is greater than 10 then
set t to t + (count every word of item i of s)
end if
end repeat
display dialog "This document has " & (count of s) & " stories, with a total of " & t & " words"
end tell
end tell
Copy link to clipboard
Copied
Thank you, but I am on Windows 7 (which makes me less cool, I know.)
Copy link to clipboard
Copied
@Peter – counting words isn't an *exact* science.
Some people would be surprised what exactly a "word" is in InDesign:
Marc Autret: What Exactly is a Word?
http://www.indiscripts.com/post/2011/09/what-exactly-is-a-word
Uwe
Copy link to clipboard
Copied
Thank you, everyone, for the information on better understanding how text/words are treated/understood by Indesign's 'brain'. This is very interesting, though a little over my head just yet. Great learning avenues though!
I still think that Adobe ought to consider making 'collective word count' command options features available for dullard creative types like me. My particular publication may have several designers working on our layouts for a given issue, so we are page proofing the articles as separate INDD documents before we compile them into a master 'Indesign Book' with the cover jacket to format for printing. It's just nice for an editor with limited software skills to be able to open one of these files and be able to tell at a glance what the word count is, even if the article uses multiple text boxes in its layout. I don't think that is asking too much. #MyTwo
Cheers, and thanks again, everyone, for the information!
Copy link to clipboard
Copied
Thank you, but I am on Windows 7 (which makes me less cool, I know.)
It's a simple script, so you might try posting it in scrpting forum and see if someone will translate it to .jsx
Copy link to clipboard
Copied
File a formal feature enhancement request as suggested in post #2 above. Without your taking this step, Adobe won't know your needs. Folks on this forum are not "Adobe people," we're users like you.
HTH
Regards,
Peter
_______________________
Peter Gold
KnowHow ProServices
Copy link to clipboard
Copied
I have a CS4-era script stashed away somewhere that counts all words in all stories and spits up a single dialog with the total document word count, but I can't find it anywhere (we only do word counts in applications that our clients use to do word counts, in order to avoid conflicts such as "what is a word in InDesign" versus "what is a word in MS Word.")
DTP Tools makes a plugin that handles this task.
Copy link to clipboard
Copied
Joel, thanks for the reminder. I often suggest those DTP plug-ins that solved problems for me. I never needed a thorough word count, so I didn't even think of this plug-in.
Joel Cherney wrote:
...
DTP Tools makes a plugin that handles this task.
Regards,
Peter
_______________________
Peter Gold
KnowHow ProServices
Copy link to clipboard
Copied
Joel --
Is this the "word count" script?
myDoc = app.activeDocument
h = 0
for ( var j = 0; myDoc.stories.length > j; j++) {
h = myDoc.stories
}
alert("You have " + h + " words in this document" )
Is this the "character count" script?
myDoc = app.activeDocument
h = 0
for ( var j = 0; myDoc.stories.length > j; j++) {
h = myDoc.stories
}
alert("You have " + h + " characters in this document" )
I know these are old; they have 2007 on them. Sorry, I don't have any other information about author.
Copy link to clipboard
Copied
Look, a simple script for a word count is a one-liner:
alert(app.activeDocument.stories.everyItem().words.length);
This uses ExtendScript's built-in definition of what a word is. What
precisely (in every grey-area case) that is I'm not sure, but it's
fairly intuitive, in my experience.
The above script does not include words in tables of footnotes. That
would be a 4-liner:
myWords = app.activeDocument.stories.everyItem().words.length;
try {myWords +=
app.activeDocument.stories.everyItem().footnotes.everyItem().words.length;}
catch(e){}
try {myWords +=
app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().words.length;}
catch(e){}
alert (myWords);
HTH,
Ariel
Copy link to clipboard
Copied
I feel curiously rewarded for having provoked this excited exchange of geekery. *Imagining myself as a child asking a question that sends my parents off on some intellectual tangent, and thinking, "Wow. Look what I did."
And I will file a features request with Adobe re: enhancing the word count automation in ID. Thank you.
Copy link to clipboard
Copied
And there are other *advanced* questions we have to ask:
Do we want to count words in text frames on the pasteboard?
How about layers with annotations, translations etc.?
How to count tables nested in tables?*
Text variables? Every instance?
*Ariel already asked that.
@Ariel: text frames in group objects are no problems:
app.activeDocument.stories.everyItem()
will catch them. Also text frames in every state of MultiStateObjects (MSOs). Even if they are nested.
Have fun!
Uwe
Copy link to clipboard
Copied
Laubender wrote:
And there are other *advanced* questions we have to ask:
Do we want to count words in text frames on the pasteboard?
How about layers with annotations, translations etc.?How to count tables nested in tables?*
Text variables? Every instance?
What about reporting these subcategories as subtotals, and the grand total as well? For example:
Visible layers
Layer 1
Words in text frames:
Words in condition 1 visible nnn
Words in condition 2 hidden nnn
Words in text variables
Words in condition 1 visible nnn
Words in condition 2 hidden nnn
Words in container tables
Words in condition 1 visible nnn
Words in condition 2 hidden nnn
Words in nested tables nn
and so on.
Copy link to clipboard
Copied
How about Grep Find
Find
\w+
Change to
$0
Results in a dialog box giving a word count.
If you want it just for Body text, then choose that style in the Find Format
Copy link to clipboard
Copied
Wicked smart, Eugene !
Copy link to clipboard
Copied
Typo: "tables OR footnotes".
Also, not sure what would happen here with nested tables, text frames in
groups, words in anchored objects, etc. That would need a bit of testing.
But a bread-and-butter doc word count it is.
Ariel
Copy link to clipboard
Copied
Some people would be surprised what exactly a "word" is in InDesign:
Just noticed that my script does not count one space in a text frame as a word the way Info does—so maybe the single space as a word is an Info bug.
Copy link to clipboard
Copied
Yes, there are ways, just not what you expected.
One approach to counting words in multiple text frames in InDesign is to thread them together. To maintain the pieces of text in their assigned threaded text frames, you can create a paragraph style that starts in the next frame, and assign it to the first paragraph in each text frame. Or, you can break the threads when the count is stable.
If the text frames need to adjust their size to the amount of their content, search Google for terms like "indesign auto resize text frame" without quotes for details.
There was a recent discussion about auto-resizing text frames that mentioned the free AutoFit InDesign plug-in, from typefi.com. Search Google for terms like "indesign typefi autofit" for details.
Search Google for terms like "threading and unthreading InDesign text frames" without quotes, for details.
Search Google for terms like "indesign start paragraph in next frame" without quotes, for details.
You can file a formal feature improvement request here: Wishform.
HTH
Regards,
Peter
_______________________
Peter Gold
KnowHow ProServices
evanexempt wrote:
I left the following comment on a Youtube tutorial explaining how to execute a word count query for an Indesign document ASSUMING your article layout uses a single box of text:
What if an article uses a creative layout with multiple text-boxes? Are you supposed to get out your pocket calculator and add them up one-by-one?
I work for a magazine that publishes short, submission-style testimonials bridged together with staff-generated narrative copy; some of our articles use six or more discreet text-boxes. You REALLY MEAN TO TELL ME that there is NO WAY to yield a TOTAL DOCUMENT WORD COUNT using what is SUPPOSED TO BE the MOST ADVANCED page layout application ON EARTH??
Pardon my exasperation in the above comment, but....Seriously?
I need someone knowledgeable to please look me in the eyes and tell me, "This is true", before I am going to be able to let myself believe it.
Thank you.
- Exasperated Journalist Slag
Copy link to clipboard
Copied
If you are using OSX this AppleScript displays the total word count:
tell application "Adobe InDesign CS6"
tell active document
set s to every story
set t to 0
repeat with i from 1 to count of s
set t to t + (count every word of item i of s)
end repeat
display dialog "This document has " & (count of s) & " stories, with a total of " & t & " words"
end tell
end tell
Copy link to clipboard
Copied
This works great except for if there is a table. Any Idea why it doesn't count words in tables? I ran this on one file and got a word count of 25. I converted the PDF to word to get a better count and came up with 17,112 words.
Copy link to clipboard
Copied
Ariel's JavaScript in #14 should get tables:
myWords = app.activeDocument.stories.everyItem().words.length;
try {myWords +=
app.activeDocument.stories.everyItem().footnotes.everyItem().words.length;}
catch(e){}
try {myWords +=
app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().words.length;}
catch(e){}
alert (myWords);
Copy link to clipboard
Copied
Thanks for giving me such a good reason to slap myself on the forehead, Eugene. I don't think I'll even need coffee this morning. That must be the simplest solution imaginable. There's no way to address Peter Gold's "advanced" wordcount concepts - no way to exclude the pasteboard, for example - but that's not really at issue here. And I wonder if InDesign's ability to count words in stories obeys the same word-boundary-identification rules that the GREP engine uses.
Copy link to clipboard
Copied
@Eugene – that is really clever… !!
@Joel – there is a way for excluding the pasteboard.
See the following script by Marc Autret:
http://www.indiscripts.com/post/2009/09/clean-up-your-pasteboard
Uwe