How to count words in any application

Lately, I have ran into the problem that I needed to count words and characters in different applications. For example, sometimes there are specific constraints on how many words I am allowed to use for a review, certain parts of a proposal, an abstract for a talk or for my short bio that I have to provide to an institution I am going to visit to give a presentation.
While a lot of text editing applications have a build-in word and character counter, not all of them have this feature. Moreover, it has happened to me quite often that I had to provide these pieces of text via a web interface, which does not provide you with any feedback on the number of words until you try to submit it.

That's why I wrote a little AppleScript and use Alfred to run it. The script counts characters, words and paragraphs in any application.

How does it work?

The script is very short and simple (see below). It has three basic steps:

  1. It takes whatever text is in your clipboard, counts the characters, words and paragraphs
  2. It sends a message to your notifications center giving you a visual feedback that the script has worked
  3. It overwrites the clipboard content with a little text telling you about the number of characters and words. I use this feature to add this information to my original text so that my collaborators can easily see if the text needs to be shorten.

The Alfred workflow

To make the script available anywhere, I have packed it into an Alfred workflow. For the trigger, i.e. to start the script, I have defined the keyword "count". You can download the full Alfred workflow here.

Of course, as always, if you don't have Alfred you can use other applications like Launchbar, Keyboard Maestro, or a service built with Automator.

How to use it?

Since the script counts words in your clipboard, you have to bring your text into your clipboard. Of course, this can be easily done by highlighting the part of the text that you want to count and copy it. I highly recommend to take advantage of shortcuts for the highlighting (e.g.⌘+A to highlight all, and others...) and copying (⌘+C).

Make it your own workflow

Everybody has their own cases where they might use this little workflow. To make it really useful for you, you should adapt it to your needs. There are a number of ways you can improve the script. The easiest one would be to change the notification text, for example, by making it more personal.

Another step is to define which information is brought back to you in the clipboard. Maybe you only need to know the number of words, or maybe you need the information on the number of paragraphs as well.
Finally, you could also split up the Alfred workflow into a number of different ones, each one of them called by different keywords (or shortcuts to make it even faster). For example, one that counts only the words and another for counting characters.

Have fun and let me know in the comments or on Twitter if it has worked for you.

Work smart, be remarkable, and have a great day!