TextEdit Word Count with Automator

I have been searching high and low for a TextEdit word count script and I found NanoCount that actually does I needed. However, I am used to using the right mouse button to find out the number of words in a text file. (You are right. I was a Windows user.)

Then I discovered Automator which comes with Mac OS X.

Mac OS X Automator

TextEdit Word Count: My First Automator Script

I have little programming background and I find the Automator extremely easy to learn. However, I am totally alien to AppleScript and so I decided to google around for similar scripts to use in Automator. Here’s the 2 web pages where I used part of the codes in my TextEdit WordCount script.

Automator Example: TextEdit WordCount Service

First, open Automator in the Applications folder. Select Services.

Step 1: Open Automator Application folder

Click at the option box “any application” to display the pull-down menu. Select Finder

Step 2: Select Services

Select Others.

Step 3: Select Finder

In the Application folder, choose TextEdit.

Step 4: Choose TextEdit

On the second column of the Automator window, search for the action “Run AppleScript” by entering “run applescript” in the search box.

Step 5: Selection Action "Run Application"

Double click at “Run AppleScript” or drag and drop this action into the workflow area.

Step 6: Drag Run Application action into the workflow area

Copy and paste the following codes into the AppleScript widows:

set word_count to count words of (input as string)
display alert "Words: " & word_count

Then, compile the codes by clicking at the hammer icon. Hammer icon

Step 7: Copy and paste AppleScript code

Save the Automator Service.

Step 8: Save the Automator Service

Next, test out TextEdit Word Count service.

Open a text file using TextEdit, highlight the text which you want to word count. Click the right button on the mouse.

TextEdit Word Count


  1. Thanks a lot for this. It was exactly what I needed! It was driving me crazy copying & pasting text out of Notational Velocity just to find out the word count.

  2. this is fantastic! I also used this to check word count in Notational Velocity– works like a charm.

    thanks for posting.

  3. If you take out the TextEdit aspect you can have it work as a service for any text you select. Super handy.

  4. If you want to keep it all in Automator, you could do something like what I’ve done:

    Make a service in automator that receives selected text (in TextEdit or “any application”)

    Then add a Run Shell Script step with the command:
    wc -w

    Then add a Speak Text command in the voice you choose.

    Now when you choose the service (I do it with command shift C), it will speak the number of words you’ve typed.

    No better or worse than the example really, but a little bit simpler and it works for me.

  5. Brilliant! It was so easy to do, and worked perfectly the first time.
    Thank you so much for taking the time to put this together for the rest of us who DON’T have any programming in our backgrounds!

  6. If you modify the script to this:

    set word_count to count words of (input as string)
    set character_count to count characters of (input as string)
    display alert “” & word_count & ” words
    ” & character_count & ” characters”

    … it will print the word as well as the character count (including whitespaces).

  7. To display both Word Count and Character Count, use these codes:

    set word_count to count words of (input as string)
    set char_count to count characters of (input as string)
    display alert "Words: " & word_count & " " & "Characters: " & char_count

Leave a comment

Your email address will not be published. Required fields are marked *