Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AppleScript to get word and character count from TextEdit
tell application "TextEdit"
set wc to count words of document 1
set cc to count characters of document 1
if wc is equal to 1 then
set txt to " word, "
else
set txt to " words, "
end if
if cc is equal to 1 then
set txtc to " character."
else
set txtc to " characters."
end if
set result to "This text comprises " & (wc as string) & txt & (cc as string) & txtc
display dialog result with title "WordStats" buttons {"OK"} default button "OK"
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment