≡ Menu

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

{ 10 comments… add one }
  • pjdube 22 Mar 2013, 8:24 am

    Or you can just use the Automator action “Get Length of Text”.

  • MyBlogSG 15 Mar 2013, 3:28 pm

    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

  • pi 9 May 2012, 9:00 pm

    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).

  • MrsD 15 Apr 2012, 2:48 pm

    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!

  • Jordy 15 Sep 2011, 10:02 am

    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.

  • Christopher 27 Jul 2011, 3:51 am

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

  • kate 26 Jul 2011, 5:05 pm

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

    thanks for posting.

  • Nick 3 Feb 2011, 2:24 am

    Thanks a million!

  • Brooks 11 Dec 2010, 3:00 am

    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.

  • Phil Morse 1 Nov 2010, 8:43 pm

    Brilliant, thanks! worked first time. I write all my articles in TextEdit (probably because I’m a geek) and this is something I was missing.

Leave a Comment