MacMost Q&A Forum • View All Forum QuestionsAsk a Question

Text Find and Replace With an Apple Shortcut?

Hi! Is there a way of using Apple Shortcuts to find and replace text with in a text string.
For example: I use inline images in Markdown documents.
The image file name might be something like “The image I want to display.jpg”
For the Markdown preview to display this image it needs to be in the form “The%20image%20I%20want%20to%20display.jpg”

So I am trying to write a Shortcut that will take to original file name from the Clipboard and replace every “space” with “%20”

Can this be done.
By the way, I am Ok with the reading the Clipboard content into a variable and copying the variable back to the Clipboard. It’s just the find and replace I’m having difficulty with.
—–
Peter Anderson

Comments: 2 Responses to “Text Find and Replace With an Apple Shortcut?”

    3 months ago

    Yes, you can do it in Shortcuts. You can also do it with my ClipTools app pretty easily (macmost.com/cliptools).

    For Shortcuts, start here: https://macmost.com/inserting-and-replacing-text-with-shortcuts.html
    That will give you a way to handle the text selected, and then you just need to work with actions to replace the text.

    For ClipTools, see: https://macmost.com/cliptools-how-to-use-smart-clips.html
    You will just need to use the {sub:} function to replace the space with %20.

    But actually ClipTools also has the function want built-in. Just select the text, choose the ClipTools menu and select: Selection Actions, URL Encode. It does exactly what you want.

    Peter Anderson
    3 months ago

    Garry,

    Thank you!

    What an idiot I am, we spoke recently and after that I got a copy of ClipTools. I've just tried it and it works brilliantly.

    I still need to follow up on a Shortcuts solution because I need to do the same encoding on my iPads.

    Regards,
    Peter

Leave a New Comment Related to "Text Find and Replace With an Apple Shortcut?"

(Your comment should relate directly to the topic of this post. Unrelated comments will simply be removed by moderators.)
:
:
:
0/500 (500 character limit -- please state your comment succinctly and do not try to get around this limit by posting two comments)