

May 06, '10 07:30:00AM • Contributed by: Simple word and character count for TextEdit



The following AppleScript adds a word (and character) count pop-up dialog to TextEdit: 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



Open AppleScript Editor's Preferences, and on the General tab, turn the 'Show Script menu in menu bar' option on. You'll then have a script icon up there, near your clock.



Now, with any TextEdit document in front of you, you can access your Word Count script from the Script menu in the menu bar. When you do, you should get a small dialog saying something like: TextEdit Word Count 2832 words. (15060 characters.) The 'OK' button dismisses the dialog box.



[crarko adds: I tested this, and it works as described.] TextEdit is far leaner than other, bulkier text editors or word processors, but it is spartan enough not to have a word count feature. So I wrote one and I thought it might be useful to somebody else.The following AppleScript adds a word (and character) count pop-up dialog to TextEdit:Copy and paste the above into AppleScript Editor (in Applications » Utilities), and save it here: ~/Library » Scripts » Applications » TextEdit. That's the Library folder in your user's directory; I called my script Word Count.Open AppleScript Editor's Preferences, and on the General tab, turn the 'Show Script menu in menu bar' option on. You'll then have a script icon up there, near your clock.Now, with any TextEdit document in front of you, you can access your Word Count script from the Script menu in the menu bar. When you do, you should get a small dialog saying something like:The 'OK' button dismisses the dialog box.I tested this, and it works as described.]

Currently 3.68 / 5 You rated: 4 / 5 (25 votes cast) [79,898 views] Hint Options Printable Hint Format

Subscribe to 'macosxhints.com application tips'





