What I want to do

I want to create a simple Automator service that:

  1. Takes text as input from any application,
  2. Does some logic on given input
  3. Replaces the selected input text with the calculated output

The problem

The return value in the JS script does not replace the selected input text. I have no clue why. Does anyone have experience with this?

I am running macOS Sierra 10.12, using Automator 2.7



The problem was related to the macOS version. After updating to 10.12.1 the text is now being correctly replaced!

Edit: for those interested in the alphabetic sorting, simply add a Run Shell Script block and fill in sort -f, like so:

Workflow script with Run Shell Script

| improve this answer | |
  • Please provide demo script for text find and replace. I want to do something like that. – wide_eyed_pupil Jun 12 '18 at 7:11
  • Sure. I edited my answer above. – Kymer Jun 13 '18 at 9:06
  • Still interested in find and replace. Automator doesn't seem to have a basic text find and replace action. I could script it but seems so fundamental I'm surprised I can't find anything. – wide_eyed_pupil Jun 17 '18 at 11:55
  • 1
    Ah you were talking about find and replace, my bad. Use the 'Run Javascript' action and make use of the String replace() function, check out docs and examples here – Kymer Jun 18 '18 at 5:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .