1 Reply Latest reply: Jul 19, 2014 3:26 PM by Hiroto
michaelsopa Level 1 Level 1 (0 points)

Hi,

 

I have the following challenge here:

 

I have text content that consists of several weblinks without a space in between. It looks like this:

 

http://www.gooogl.com/https://abc.org/http://banana.com/http://skydive.net/ etc.

 

What I'd like to do in Automator is to create an action that enters a new paragraph ahead of every address, so that it will finally look like this:

 

http://www.gooogl.com/

https://abc.org/

http://banana.com/

http://skydive.net/

 

I hope you get the idea :-)

 

My text input will be in pages, but if that doesn't work than I switch to TextEdit.

 

So, how do I do this? Right now I enter the paragraphs manually but this text has several hundreds of lines.

 

Appreciate your help.

 

Thanks,

Mike


MacBook Pro, OS X Mavericks (10.9.4), Automator
  • Hiroto Level 5 Level 5 (6,030 points)

    Hello

     

    You may create an Automator service as follows:

     

    Automator Service:

        Service receives selected [text] in [any application],

        Replaces selected text [checked]

     

        Workflow:

            Action = Run Shell Script action

                Shell      = /bin/bash

                Pass input = to stdin

                Code       =

              

    /usr/bin/perl -CSDA -pe 's%.(?=https?://)%$&\n%og;'
    
    

          

     

     

    Service workflow will look like this:

     

    a.png

     

     

    To use it, select text and invoke service (from Services menu or keyboard shortcut you assigned) and it will replace the selected text with the processed text.

     

     

    Hope this may help,

    H