Skip navigation
Marcos Suárez
Currently Being Moderated

Count words in a book of InDesign CS4

Jul 26, 2012 6:37 AM

With this script we can count the words, paragraphs and footnotes in a document indesign ...

But I need to make this count in a book of InDesign ...

Any ideas?

 

 

var docWordCount = app.activeDocument.stories.everyItem().words.length; // words
var docParCount = app.activeDocument.stories.everyItem().paragraphs.length; // paragraphs
var docNoteWordCount = app.activeDocument.stories.everyItem().footnotes.everyItem().words.length; // words in footnotes
var docNotesCount = app.activeDocument.stories.everyItem().footnotes.length; // footnotes
 
// TABLAS *************************************************************************************************************************
var docTableWordCount = 0;
if (app.activeDocument.stories.everyItem().tables.length)
    {
        docTableWordCount = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().words.length;
    }
 
// ***********************************************************************************************************************************************************************
var myDocWordCount = docWordCount + docNoteWordCount + docTableWordCount;
alert("Tienes " + myDocWordCount + " palabras, " + docParCount + " párrafos y "+ docNotesCount + " notas en el documento. Ojo, también se incluyen págs. maestras, pero no sus textos repetidos en maqueta   ", "RECUENTO DE PALABRAS, NOTAS Y PÁRRAFOS (MSP)");
 
Replies
  • Currently Being Moderated
    Jul 26, 2012 10:29 AM   in reply to Marcos Suárez

    Try this:

    var docWordCount = app.books[0].documents.everyItem().stories.everyItem().words.length; // words
    var docParCount = app.books[0].documents.everyItem().stories.everyItem().paragraphs.length; // paragraphs
    var docNoteWordCount = app.books[0].documents.everyItem().stories.everyItem().footnotes.everyItem().words.length; // words in footnotes
    var docNotesCount = app.books[0].documents.everyItem().stories.everyItem().footnotes.length; // footnotes
     
    // TABLAS *************************************************************************************************************************
    var docTableWordCount = 0;
    if (app.books[0].documents.everyItem().stories.everyItem().tables.length)
        {
            docTableWordCount = app.books[0].documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem().words.length;
        }
     
    // ***********************************************************************************************************************************************************************
    var myDocWordCount = docWordCount + docNoteWordCount + docTableWordCount;
    alert("Tienes " + myDocWordCount + " palabras, " + docParCount + " párrafos y "+ docNotesCount + " notas en el documento. Ojo, también se incluyen págs. maestras, pero no sus textos repetidos en maqueta   ", "RECUENTO DE PALABRAS, NOTAS Y PÁRRAFOS (MSP)");
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 10:30 AM   in reply to Harbs.

    That should have been app.books[0].bookContents.everyItem() instead of app.books[0].documents.everyItem()...

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points