Shortcuts Find & Replace

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.

Regards,
Peter

There are a couple of options for this. You can use the Replace action or the URL Encode action

Sample Shortcut

Hope this helps.

1 Like

Tony,

WOW! Thank you!

That worked and gives me enough to develop it for my workflow.

I’m very new to Shortcuts and didn’t know about “Replace … with”.

Do you have any hints or good sources for a Shortcuts novice?

Regards,
Peter

Glad that it helped.

There are a few resources that can help:

All have some free Shortcuts and some behind their memberships.

I haven’t used any of the listed resources recently, but they are generally positively mentioned.

There are also a number of reddits for shortcuts (iOS, macOS, Advanced) but I have not looked at any of these.

A lot of Shortcuts is just trying it and looking through the list of available actions in the editor or the user guide or looking at some of the Shortcuts available in the Gallery in the Shortcuts app.

If you get stuck at any stage, post a link to the Shortcut as far as you have got on here or the Automators Discourse forum (the podcast has finished but the forum still exists with some other awesomely helpful users) and usually people will try to help.

Hope this helps.

That’s a great tip, Tony. Thanks for sharing it with all of us.

I still use the 8.3 naming convention, but maybe I can rethink that :rofl:

Kirk,

Hi! I do a great deal of writing in Markdown. If the document has inline images then I name the image files similar to the document. That way when viewed in Finder or Files they all appear together. For example:

Dutton says nuclear will cost $331 billion.md

Dutton says nuclear will cost $331 billion 01.jpg

Dutton says nuclear will cost $331 billion 02.jpg

Hence the need for encoding the spaces.

Regards,
Peter

1 Like