Dec242012

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

Piseth Mao asks:

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.


Browser: Safari 6
System: Mac
Tagged: , , , ,

2 Answers - Write an Answer

0 votes
Reply

Jan Fritsch

December 24, 2012

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:
http://myblogsg.com/textedit-word-count/
http://www.cultofmac.com/166707/count-words-characters-and-paragraphs-with-a-roll-your-own-automator-service-os-x-tips/

0 votes
Reply

ha14

December 24, 2012

Use AppleScript to count words and characters in text
http://hints.macworld.com/article.php?story=20070730101510623

nslater / Word and Character Count.scpt
https://gist.github.com/1616556
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.

Write an Answer

Log in to MakeUseOf using one of your online accounts below.
(Why? Earn points, unlock giveaways, access exclusives)

Or, comment anonymously