Word count

I couldn't find this anywhere in the forums, but is there any way to get a "Word count" field in Directory Opus or plans to implement this? I'm a translator and its useful for me to be able to see at a glance how many words a relevant file type (mostly *.docx) contains.

Thanks,

Olly

A script or shell extension could add such a column, but would need to have a way to calculate the data from a .docx file, which may not be easy. (Getting the plain-text out via the IFilter is probably the right approach, but I'm not sure it's possible from VBScript, so probably requires C++ code or similar to be written.)

Interestingly, Explorer has a Word Count column, but it seems unreliable. I saved a document with "This is a test file." and while Word itself reported it as having 5 words, Explorer reported 3 words. So hooking into that existing column seems a non-starter, unless you want it to ignore short words (I assume that's what it is doing).

Hi Leo,

Thanks for your reply. That's interesting; I always assumed Explorer's Word Count reproduced Word's own count, but I did a quick comparison and I see you are right! If the count is not reasonably reliable (as much as one can be) then it is indeed no use to me.

Try this to extract the content from your Word-Doc:

wrd = new ActiveXObject('Word.Application'); wrd_file = wrd.Documents.Open('test.docx'); wrd_file_content = wrd_file.Content; wrd_file.Close();

Now you have to count the words in string wrd_file_content
Maybe sth. like this will work (untested!):

[code]function countWords(myString) {

var count = 0;
var words = myString.split(' ');
for (i = 0; i < words.length ; i++) {
if (words[i] != '')
count += 1;
}

return count;

}[/code]

Here you go, Column: Word Count for Microsoft Word documents.

Turned out to be quite complicated to get right, but it seems to work.