Alex's Blog

Parsing Raw Plain Text with Apple Shortcuts

This is an obscure post but I hope it will one day help someone who finds it via Google or whatever.

I wanted to use the "Get contents of URL" action in Apple Shortcuts to load the contents of an ICS file and do some very basic parsing of all the events in it. But I found whenever I ran it and tried to access the page content it did the HTTP request but I just got a portion of the URL back (which I think Shortcuts considers the "Name" of what I loaded?), and I couldn't figure out how to get just the raw plain text content from the load.

After a bunch of Googling and nearly giving up I eventually found a Reddit thread where someone had the same problem trying to parse some XML as plain text. Which had a comment from a now deleted user saying Set name to *.txt Get text from input. It then took me some additional time to figure out what they meant is to use the Set Name action in Shortcuts to something ending in .txt and then Shortcuts parses it as plain text.

I can't believe how obtuse and unfindable that solution is, but it totally works. So I'm documenting it here in the hopes of helping future generations. Here's what your Shortcut should look like:

Apple Shortcut using a Set Name action to get raw plain text to then parse

If you run something like the above the Renamed Item should contain the plain text of what you loaded, as you can see above where it's outputting the raw HTML rather than simply rich text (as it would without the Set Name action).

If this helped you, then consider letting me know on Mastodon as I'd be happy to hear it!

Recent posts