Count Words In Pages, TextEdit and Everywhere

There is a quick and easy way to see your document or selected word count in Pages. In TextEdit, there is a simple trick you can use to reveal the document word count. You can also write a simple two-line AppleScript service in Automator to count the words in selected text in almost any application on your Mac.

Video Transcript
Now from time to time with writing you want to know how many words you've written or how many words are in a selection. This is easy to do in some cases and very difficult to do in others. For instance, here in Pages if we wanted to know how many words are in this document I can just go to View and then choose Show Word Count. At the bottom here you'll see a little list here that shows how many words. You can click on this list and it will show you even more things like characters, characters without spaces, paragraphs, things like that. Also if you select some text, like I'll select this paragraph here, it changes to show you how many words are in the selection. If you have no selection it shows you how many words are in the full document.

So this is great if you're given yourself a quota of the number of words you want to write per day. You can select what you've written so far and see how many words are there as opposed to the entire document.

In TextEdit there is no option to show word count. But you can use a little trick to find out how many words are in a document. So what you want to do is go to Edit and Find. Then you can search for something. So, for instance, say I search for a word here that's here twice. Notice it has the number two there because it found it twice. So instead of searching for a word I'm going to click here on the little magnifying glass and Search for Pattern. The pattern I'm going to choose is a word. Now it's going to find all the occurrences of a word. Which there are a lot of. There's 209. You can see the same number there. So that little trick in Find gives you the ability to find every word and give you a total for the number of words in that document.

But that still doesn't give you the ability to find out how may words are in a selection. And in other apps you don't have that ability. So here I am, for instance, in Mail. I want to see how many words are in my email message. I can't do it. But I can now use Automator and create a simple service that will allow me to check the word count of any selection in any app that I'm using.

So let's run Automator. Do Command space and search for Automator and run it. Then I'm going to choose New and create a Service. The Service will allow me to then use any text I've selected as input. So you can see here at the top Service receives selected text in any application. So far so good. What do I want to do with that? Unfortunately there's not going to be something in here that's a magical show me my word count thing. But I can do a script.

So I'm going to search for script. I'm going to use an AppleScript in this case because it will be really easy to do. I'm going to paste this two line script in here. So you can see the two lines are: set numbwords, which is a variable name I've created, to the number of words of, and then in parentheses (input as string) because the input comes in and you have to tell it you want to treat it as text. So that's why I'm using AppleScript rather than JavaScript even though I like using JavaScript just because AppleScript has a very nice number of words function there that will quickly give me an answer. Then I'm going to display a dialog that's just the text word count in quotes, colon, space, followed by the value numbwords.

So let's save this. I'll save it as a Service called Selected Text Word Count. Now when I go into Mail here I can choose it one of two ways. One I can go to Mail, Services, and I can see Selected Text Word Count and it will give me the result. 209 words. I can also, since I have text selected here, Control click on it, or whatever you use for your contextual menu click, and I can select Services and Selected Text Word Count under there as well to bring it up.

So now I have the ability to find the word count in any app where I'm typing text. I can even do it in web forms, for instance, in Safari.

Comments: 2 Responses to “Count Words In Pages, TextEdit and Everywhere”

    John
    2/12/18 @ 1:05 pm

    Gary, never attempted to use Automator before. Followed your train, but no idea how to define “numwords” so that the Service (script) will actually run.
    BTW I wouldn’t be trying to do this if WordCount thing did not have value for me. Thanks for your time on this!

    2/12/18 @ 1:26 pm

    John: Just follow the steps in the video. Maybe go over it again carefully to make sure you are making the same choices I am.

Comments Closed.