Count the Number of Words and Characters in a Google Document
If you were to count the nubmer of words and characters in a Google Document, open the document, go to the Tools menu and choose Word Count. That’s a good option for counting words in a single document manually but what if you have a folder of files in Google Drive, say student assignments, and wish to know the words or characters per document. That’s where Google Apps Script can help. Go to Tools > Script Editor and paste the code to programmatically get the word count of any document in Google Document. You can either provide the document ID to the function or it will use the currently opened document. function getWordCount ( fileId ) { const SEPARATOR = ' ' ; const document = fileId ? DocumentApp . openById ( fileId ) : DocumentApp . getActiveDocument ( ) ; const text = document . getBody ( ) . getText ( ) ; const words = text . replace ( /\s+/g , SEPARATOR ) . split ( SEPARATOR ) ; const characters = words . join ( '' )...