Search this site
Twitter
Facebook

Moments
Photo stream
Navigation
Powered by Squarespace
« Flirting with NetNewsWire | Main | Zuma aint no Obama »

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:
, ,


Reader Comments (14)

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!

Jan 11, 2008 at 12:58 | Unregistered CommenterMartin Michel

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!

Jan 11, 2008 at 13:58 | Unregistered CommenterMartin Michel

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!

Jan 11, 2008 at 13:58 | Unregistered CommenterMartin Michel

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!

Jan 11, 2008 at 13:58 | Unregistered CommenterMartin Michel

Ooh, fantastic, thanks very much. I'll try that out!

Jan 11, 2008 at 14:27 | Unregistered CommenterPaul

Ooh, fantastic, thanks very much. I'll try that out!

Jan 11, 2008 at 15:27 | Unregistered CommenterPaul

Ooh, fantastic, thanks very much. I'll try that out!

Jan 11, 2008 at 15:27 | Unregistered CommenterPaul

Ooh, fantastic, thanks very much. I'll try that out!

Jan 11, 2008 at 15:27 | Unregistered CommenterPaul

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

Feb 12, 2008 at 12:42 | Unregistered CommenterBusiness Entertainment Free

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

Feb 12, 2008 at 13:42 | Unregistered CommenterBusiness Entertainment Free

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!

Feb 24, 2008 at 21:26 | Unregistered CommenterJoshua

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!

Feb 24, 2008 at 22:26 | Unregistered CommenterJoshua

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!

Feb 24, 2008 at 22:26 | Unregistered CommenterJoshua

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!

Feb 24, 2008 at 22:26 | Unregistered CommenterJoshua

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>