Counting the words in a folder

Hi
Guidance please. In my work I need to know the word count of a folder of files. I know there is an Applescript in the edit menu to count words for a selection. However ideally I would like this viewable on a live basis in the main window. Does anyone know how to show the word count of folders in this way? Any help much appreciated. thanks

It’s not possible to modify the user interface via scripting.

OK thanks Christian. While I guess not a high priority, since I imagine its a quick bit of code, would be great to see this feature appear in 2.0 :slight_smile:. I guess a lot of others who use DT Pro to write would also like to know the word count of folders live - especially those who split a writing project into chapter folders. thanks for the quick reply anyway.

I asked for something similar – a way to search for documents by word count – that currently requires one to (I believe) query each individual file for its word count.

Perhaps word count could be calculated whenever a file is saved and entered as a value of a field in the database, if this isn’t done already. That might solve both of our problems.

I did something much like what you are looking for with AppleScript. Basically, I searched for all of my files with “Draft” in the name, then looped through with a repeat and added their word counts together, then updated my iChat status message with the result.

It looked something like:


tell application "DEVONthink Pro"
			set theWordCount to 0
			set theRecords to search "Draft" within titles
			repeat with thisRecord in theRecords
				set theWordCount to theWordCount + (the word count of thisRecord)
			end repeat
end tell

Of course, if you’re like me and want to preserve the word “Draft” in the titles of older drafts, it becomes a lot more complicated.

You could probably set up a smart group to trigger a script like this and have the script change the smart group’s name to the word count – but that’s hardly optimal, I don’t think.

I wish I could help more.

Many thanks. I will try this out.

Could content statistics be a feature in DTP 2.X?

Currently, the status bar reads something like “Filename (type, size, modified) … # paragraphs, # words, # characters” when viewing an RTF file, for instance. Nothing to complain about – that’s wonderful, I think.

If a group view showed something like the “# items, # selected” that it currently does, along with a “# paragraphs, # words, # characters” reflecting the totals of the documents in that group, that might be nifty.

Of course, I don’t know of a quick way to do that without creating extra fields for every document in the database, and there are things I’d much rather see in DTP2 than that, but I thought I’d suggest it. Even if it’s annoying or prohibitive in some way to code it, it doesn’t hurt to express the (mild) desire.