Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use AppleScript to count words and characters in text' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use AppleScript to count words and characters in text
Authored by: NovaScotian on Jul 31, '07 12:36:22PM

A version that counts what in a file:

set f to (choose file with prompt "Choose a text file" without invisibles)
tell application "Finder" to open f -- brings it to front if open
delay 0.5 -- may have to be lengthened if doc is not open.
tell application "System Events" to tell window 1 to keystroke "ac" using command down -- command a is "all", command c is "copy".
tell (the clipboard) to set {char, wds, para} to {count characters, count words, count paragraphs}



[ Reply to This | # ]