RSH458

Q: TextEdit word count

I haven't been able to find a word count for a TextEdit document. I'm occasionally required to write to a certain word limit. How can I get a word count on a TextEdit document? Thanks.

Mac OSX 10.8.5

Posted on Mar 25, 2015 10:55 AM

Close

Q: TextEdit word count

  • All replies
  • Helpful answers

  • by Niel,

    Niel Niel Mar 25, 2015 10:57 AM in response to RSH458
    Level 10 (313,215 points)
    Mac OS X
    Mar 25, 2015 10:57 AM in response to RSH458

    Choose Utilities from the Finder's Go menu, open the AppleScript Editor, and run:

     

    tell application "TextEdit"

    count words of document 1

    end tell

     

    (124834)

  • by RSH458,

    RSH458 RSH458 Mar 25, 2015 11:13 AM in response to Niel
    Level 1 (0 points)
    Mar 25, 2015 11:13 AM in response to Niel

    I followed those directions but got a message saying "the variable HUNT032615 (the name I gave the document) is not defined."

     

    Am I supposed to use something other than the name of the document?

     

    Also, is there a way to set TextEdit up so it gives me a word count on all documents as the default position?

     

    Thank you very much

  • by Niel,

    Niel Niel Mar 25, 2015 11:15 AM in response to RSH458
    Level 10 (313,215 points)
    Mac OS X
    Mar 25, 2015 11:15 AM in response to RSH458

    You're supposed to run the script as posted or put the document's name inside double quote marks.

     

    (124836)

  • by RSH458,

    RSH458 RSH458 Mar 25, 2015 11:26 AM in response to Niel
    Level 1 (0 points)
    Mar 25, 2015 11:26 AM in response to Niel

    Ah, that worked.

     

    But I gather there's no way to set up TextEdit so that as a default the word count is displayed somewhere in the document interface, right?

     

    Niel, thanks very much for your help.

  • by Niel,Solvedanswer

    Niel Niel Mar 25, 2015 11:28 AM in response to RSH458
    Level 10 (313,215 points)
    Mac OS X
    Mar 25, 2015 11:28 AM in response to RSH458

    Correct.

     

    (124838)

  • by Tony T1,

    Tony T1 Tony T1 Mar 25, 2015 11:50 AM in response to RSH458
    Level 6 (9,249 points)
    Mac OS X
    Mar 25, 2015 11:50 AM in response to RSH458

    You can also save this Automator Workflow (as WordCount) as an Automator Service, then ⌘A in TextEdit, right click and select WordCount:

     

    Screen Shot 2015-03-25 at 2.49.43 PM.png

     

    osascript <<-AppleScriptHereDoc

    tell application "TextEdit"

      set word_count to count words of document 1

      set char_count to count characters of document 1

      set show_words to (word_count as string) & " words. (" & (char_count as string) & " characters.)"

      set dialog_title to "TextEdit Word Count"

      display dialog show_words with icon 1 with title dialog_title buttons {"Ok"} default button "Ok"

    end tell

    AppleScriptHereDoc

  • by bellycelli,

    bellycelli bellycelli Jun 8, 2015 10:42 AM in response to RSH458
    Level 1 (0 points)
    Jun 8, 2015 10:42 AM in response to RSH458

    Niel's solution worked, and I found another by clicking here.  I'm so not an expert.  So it took me awhile to realize that the author's first step means to select the wheel icon marked "Service" right off in automator.  The plain Workforce that is already highlighted does not have that top step 1. business you need.  After everything and clicking untitled in the top middle to save the creature as Word Count, I do not know if I was supposed to click Run.  I did quit automator and couldn't find my Word Count anywhere.  Then I went back in automator and tried to Open Recent.  It offered me the option to Install, which I did.  Then Word Count worked every time I right clicked on my highlighted text in the text edit.  Yippee!

  • by VikingOSX,Helpful

    VikingOSX VikingOSX Jun 8, 2015 11:40 AM in response to RSH458
    Level 7 (21,014 points)
    Mac OS X
    Jun 8, 2015 11:40 AM in response to RSH458

    Another way to see a word count in TextEdit involves the Find (command+F) tool. Once you have launched it, press the search icon in the left of the input field. At the bottom of this menu, select Insert Pattern. Then click the menu item, Any Word Characters. The word count will appear on the right side of the Find input window.

    Screen Shot 2015-06-08 at 2.34.58 PM.png

     

    This was also verified with WordService Statistics service from the free Devon Technologies WordService collection in the OS X App Store.