Automator Find and Replace Text issues

Hi - I'm trying to do what should be a simple task in automator, but have had no luck after more than an hour, and I can't understand what I'm doing wrong. I download transaction history from my brokerage account, and I want to change how the data is formatted. As one example, the downloaded file will read "Bought to Open," which I want to change to "BTO."


I create a new Automator Service, and drop in a "Find and Replace Text" node. At the top the service receives selected text in any application, and I enter Bought to Open in the Find box, and BTO in the replace box. I save that service as BTO in automator, then go to the text file that has all the information, select all the text of the document, then control-click and select BTO from the drop down menu. I get an error which reads "Automator could not convert the input data to the desired type." Huh? There doesn't seem to be any relevant commands when I type "convert" in the search field for automator, nor does it seem logical that I would need to convert text at all in order to execute a simple find and replace. What am I doing wrong, or what am I missing? Thanks.

Posted on Aug 17, 2015 12:58 AM

Reply
6 replies

Aug 17, 2015 5:07 AM in response to Keith Huggins

I don't see a generic "Find and Replace Text," only one for Word Documents. In that action, you must pass it a com.microsoft.word.document.object, not plain text.

You might try installing this package of actions: http://automatorworld.com/archives/textedit-action-pack/

I have not used them, but the same thing applies. You must ensure you are passing it data that it expects.

Aug 17, 2015 5:18 AM in response to Keith Huggins

Another way to do it would be to use the stream editor (sed) in a run shell script to do the replacements. You could pass the entire file to the script and have sed replace the strings.

You could create a list of sed commands that would do all of your editing at once.

http://www.thegeekstuff.com/2009/09/unix-sed-tutorial-replace-text-inside-a-file -using-substitute-command/

Aug 17, 2015 10:11 PM in response to Barney-15E

Now that you mention it, its icon was different from the others, and if I had a microscope, I guess I could have seen that it had a tiny W on it.


So that text action pack worked as expected, thanks. But I had to spend $15 to buy the full pack so it didn't give me a notice every time I ran the script. Not a big deal, but one would expect that that's such a basic action, it would have been included as one of the functions of the software. Anyway, thanks for your help!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator Find and Replace Text issues

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.