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
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.
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