Where can I find a script for Automator to count selected text?

Piseth Mao December 24, 2012

Can anyone share with me the script for Automator to count selected? I want to create an Automator service to count selected text, but I found out there is no available action from the list. I would very much thank you for sharing this script with me. Thanks.

  1. ha14
    December 24, 2012 at 5:15 pm

    Use AppleScript to count words and characters in text

    nslater / Word and Character Count.scpt
    Use Automator.app to create a new service, and then select the Run AppleScript action. Paste this code in to the text box, and save as Word and Character Count. Now switch to a new app, select some text, and open the context menu to find the new option.

  2. Jan Fritsch
    December 24, 2012 at 8:39 am

    I don't think you can do this with Automator alone ~ it merely enables you to automate a batch of tasks, create a workflow for things you'd usually do via the menus.

    You'll need to save the selected text to a string and then forward it into a script (bash, AppleScript, perl) which will then do the counting.

    two examples: