Like herding cats, only with words
January 17, 2011 1:35 PM   Subscribe

Is is possible to count words across multiple documents?

I need to track the total number of words in a folder full of .docx documents (created in Word 2011 for OS X), each of which is being added to regularly.

This little app, Word Counter, would be absolutely perfect, except that alas! It does not recognize .docx files, only .doc files.

Thanks in advance for any ideas!
posted by bunji to Computers & Internet (9 answers total) 2 users marked this as a favorite
Best answer: You could rename all the file extensions from .docx to .doc and then use the app you mentioned. It's just as easy to convert them back to .docx.
posted by foraneagle2 at 1:58 PM on January 17, 2011

If you are familiar with the Terminal and shell scripting, you can use docxtotext to extract the text from each file and count the words that way. It probably won't give an exactly accurate count, but it will be close.
posted by procrastination at 2:12 PM on January 17, 2011

Some kind of vbScript would be the safest way.

Paste and save the following as "count.vbs" file on your desktop. Change the folder name, and double click to count the words.

(Of course - In the half an hour it's taken me to do this, someone else will have posted a better way... Sigh)
on error resume next 

 Set fso = CreateObject("Scripting.FileSystemObject")
  sFolder = "c:\Users\Sean\Desktop\"

  Set folder = fso.GetFolder(sFolder)
  Set files = folder.Files
  Set objWord = CreateObject("Word.Application")
  iWords = 0 
  For each folderIdx In files
    sFileName = Ucase(
	if (right(sFileName,4)) = "DOCX" then
        Set objDoc = objWord.Documents.Open(
		iWords = iWords + objDoc.Words.Count
	end if
wscript.echo ("Number of words: " & cStr(iWords))

posted by seanyboy at 2:39 PM on January 17, 2011

Here's that file tidied up.
posted by seanyboy at 2:47 PM on January 17, 2011

If you're on OSX, can you save the files to plain text, then count them in the terminal with 'wc'?

wc file1 file2
prints stats for file1, file2, and the total.
posted by ctmf at 2:48 PM on January 17, 2011

Sorry - I missed the OSX thing. My answer was for Windows.
posted by seanyboy at 2:50 PM on January 17, 2011

Response by poster: Many intriguing ideas, but I was hoping to stay away from having to convert all the files (there are a lot of them, all edited frequently!)

While I'm surprised there isn't a simpler way to count words within a directory, at least I don't feel like a complete dolt for overlooking some glaringly obvious solution.
posted by bunji at 3:30 PM on January 17, 2011

There are simpler ways to count words in docx files within a directory, but in terms of software solutions, I can't think of any that do so and are free. If you have any money to put towards your solution, you might look at Practicount, which can count words for all files in a directory, and which is free to try for 15 days and $60 to license.
posted by drlith at 5:34 PM on January 17, 2011

Oh, foo. Missed the OS X requirement also.
posted by drlith at 5:36 PM on January 17, 2011

« Older Hebrew & Chinese translations?   |   This is tax evasion, right? Newer »
This thread is closed to new comments.