Reply To: Word Count a book

#56730

Yes, thats it. Thanks a lot!

The final code:

//DESCRIPTION:Count Words of Opened Documents

// A Jongware Script 18-Aug-2010

words_a = 0;

words_b = 0;

//loop

for (var d=0; d<app.documents.length; d++)

{

doc = app.documents[d];

words_a += countWords_a (doc);

words_b += countWords_b (doc);

}

//alert message

alert (“Number of words: “+words_a+”rOr possibly (by GREP): “+words_b);

//word count function a

function countWords_a (aDoc)

{

var w = aDoc.stories.everyItem().words.length;

return w;

}

//word count function b

function countWords_b (aDoc)

{

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = “w+”;

var w = aDoc.findGrep().length;

return w;

}

This article was last modified on August 18, 2010

Comments (0)

Loading comments...