Word count for TextEdit

I don’t know if anyone else has been wondering why Apple left a word count feature out of TextEdit but I certainly have been. Granted I have a couple word processors that are chock full of cool features including a word count but sometimes I like to use TextEdit because it is lightweight, simple and fast.

Anyway, I asked Google about a word count feature for TextEdit and one of the results was this easy Applescript option that works pretty well even if it involves running the script as a separate item to TextEdit. To run this you need to open the Script Editor in the /Applications/AppleScript/ folder:

tell application “TextEdit”
count words of document 1
end tell

Thanks to Niel for posting the solution.


Technorati Tags:
, ,

Paul
Enthusiast, marketing strategist, writer, and photographer. Passionate about my wife, Gina and #proudDad. Allergic to stupid

  1. Hi Paul,

    your code example sometimes returns strange results. For example, it returns 10 words for a document which in fact contains 100 words. So I enhanced your script a bit and came up with the following version:

    tell application "TextEdit"

    activate

    set doccont to text of document 1

    set docname to name of document 1

    set wordcount to length of (words of doccont)

    set paracount to length of (paragraphs of doccont)

    display dialog "The frontmost document* contains:" & return & return & "Words: " & wordcount & return & "Paragraphs: " & paracount & return & return & "* " & docname buttons {"OK"} default button 1 with title "Text infos for TextEdit"

    end tell

    This one also counts the paragraphs.

    Best regards to South Africa from Germany!

  2. Hi Paul,

    your code example sometimes returns strange results. For example, it returns 10 words for a document which in fact contains 100 words. So I enhanced your script a bit and came up with the following version:

    tell application "TextEdit"

    activate

    set doccont to text of document 1

    set docname to name of document 1

    set wordcount to length of (words of doccont)

    set paracount to length of (paragraphs of doccont)

    display dialog "The frontmost document* contains:" & return & return & "Words: " & wordcount & return & "Paragraphs: " & paracount & return & return & "* " & docname buttons {"OK"} default button 1 with title "Text infos for TextEdit"

    end tell

    This one also counts the paragraphs.

    Best regards to South Africa from Germany!

  3. Hi Paul,

    your code example sometimes returns strange results. For example, it returns 10 words for a document which in fact contains 100 words. So I enhanced your script a bit and came up with the following version:

    tell application "TextEdit"

    activate

    set doccont to text of document 1

    set docname to name of document 1

    set wordcount to length of (words of doccont)

    set paracount to length of (paragraphs of doccont)

    display dialog "The frontmost document* contains:" & return & return & "Words: " & wordcount & return & "Paragraphs: " & paracount & return & return & "* " & docname buttons {"OK"} default button 1 with title "Text infos for TextEdit"

    end tell

    This one also counts the paragraphs.

    Best regards to South Africa from Germany!

  4. Hi Paul,

    your code example sometimes returns strange results. For example, it returns 10 words for a document which in fact contains 100 words. So I enhanced your script a bit and came up with the following version:

    tell application "TextEdit"

    activate

    set doccont to text of document 1

    set docname to name of document 1

    set wordcount to length of (words of doccont)

    set paracount to length of (paragraphs of doccont)

    display dialog "The frontmost document* contains:" & return & return & "Words: " & wordcount & return & "Paragraphs: " & paracount & return & return & "* " & docname buttons {"OK"} default button 1 with title "Text infos for TextEdit"

    end tell

    This one also counts the paragraphs.

    Best regards to South Africa from Germany!

  5. Tips for hurdle free Bad Credit Business Loans…

    Are you as a business person thinking that your bad credit may come in the way of borrowing from a professional lender? Well you need not to worry at all as there are many lenders around who are devoted to bad credit business loans….

  6. If you use Quicksilver and invoke the script through it, it will run and tell you how many words are in the document. This is no big extra, but seems more convenient than keeping Script Editor open.

    This is really a great script. Thank you Martin, Niel, et al. for the great work!

  7. If you use Quicksilver and invoke the script through it, it will run and tell you how many words are in the document. This is no big extra, but seems more convenient than keeping Script Editor open.

    This is really a great script. Thank you Martin, Niel, et al. for the great work!

  8. If you use Quicksilver and invoke the script through it, it will run and tell you how many words are in the document. This is no big extra, but seems more convenient than keeping Script Editor open.

    This is really a great script. Thank you Martin, Niel, et al. for the great work!

  9. If you use Quicksilver and invoke the script through it, it will run and tell you how many words are in the document. This is no big extra, but seems more convenient than keeping Script Editor open.

    This is really a great script. Thank you Martin, Niel, et al. for the great work!

What do you think?

%d bloggers like this: