Counting the number of words in a file is probably something you do when you’re in college and you have a paper of a specific length to turn in. There are few other occasions when you would actually need to count the number of characters or words in a file, but if you do, there isn’t a quick way to do so in Mac. A Terminal command does exist that counts characters in a text file, but if you need a more universally applicable solution, you can use this script to create a service that does just that. You will be able to run it from the context menu, and can forgo having to copy text to the clipboard and then pasting it into an app that does the same.
Open the Automator and select Service when it asks you what you want to create. To create a service, you will need to add an action; in this case, it will be Run AppleScript. Make sure that Text is selected under Service receives selected and Any application is selected in the second dropdown. Paste the following script and save it with any name that will help you remember what the service does.
on run {input, parameters}
try
set MyText to input as string
set NombreSignes to the number of characters of MyText
set NombreMots to the number of words of MyText
set NombrePara to the number of paragraphs of MyText
set LeResultat to "The selected text contains :" & return & "- " & NombreSignes & " sign(s) ;" & return & "- " & NombreMots & " word(s) ;" & return & "- " & NombrePara & " paragraph(s)."
display dialog LeResultat buttons {"OK"} default button 1 with icon note
on error errmsg number errnum
display dialog errmsg & " [" & errnum & "]" buttons {"OK"} default button 1 with icon stop
end try
return input
end run
Go to any app, select text, right-click and choose Services > Name Of Service You Just Created, and small window will appear, giving you the total word, character and paragraph count for the selected text.

The response is a bit slow, but the service works perfectly otherwise. The service will be available in any and all applications that support text.


