Tapped out

Have I ever mentioned how frustrating I find programming in Shortcuts? I have? Well, I’m going to do it again. This time, I’m going to vent about Magic Variables, which everyone says are great but which I despise. Sort of.

First, let me thank Tim Nahumck for gently telling me on Twitter that my Image Info shortcut was horrifically (my word, not Tim’s) inefficient and could be cut down from sixteen steps to just one.1 This one:

Finished shortcut

All those green bubbles come from a single Magic Variable and its many parts. I’m going to show how to put them together—partly because it might help you, but mostly in the hope that doing this will reinforce the use of Magic Variables with me.

First, add the Show Result action to a blank shortcut and tap in the text field to start editing.

Show Result step

We want to get a property of the image that’s the input to the shortcut, so we tap on the magic wand button above the keyboard to get a new view of the shortcut that shows where the Magic Variables are. Because this shortcut is so small, there’s only one, the Shortcut Input.

Show Magic Variables

Tap on that green bubble to add it to Show Results. Once you see it in the Show Results text field, tap on it there to bring up a list of its properties.

Select Magic Variable properties

Since we want the Name property, tap on it, and the property will show up as a sort of extension to the green bubble.

Magic Variable with property selected

After adding a period after the name, we add that same Shortcut Input Magic Variable a second time, but this time we scroll down to choose the File Extension property.

Choosing File Extension part

Keep doing this again and again, each time choosing a different property of the Shortcut Input. When we’re done, we get this, which I’m showing in a wider view, so you can see the line breaks.

Finished shortcut

This is a far more idiomatic shortcut than my original. Not just because it’s one step instead of sixteen, but because it leverages Shortcuts’s real power, much of which lies in its Magic Variables. Which I hate.

OK, I don’t really hate Magic Variables themselves, what I hate is this hunting around to figure out where they are (in multi-step shortcuts, they appear throughout the workflow) and what they can do. Intellectually, I know this is essentially the same as looking through documentation, but it feels different. Documentation allows you to get a broader view of the capabilities of a language; even when you’re looking up a specific feature, in good documentation you see related features at the same time. Shortcuts treats this process like a game of hide and seek.

And although my inefficiency in building the original version of this shortcut was due to my ignorance, even after Tim cured me of that ignorance, the tap-tap-scroll-tap bullshit of adding each new piece to the Show Results step was maddening. The Shortcuts programming environment doesn’t reward you for knowing what you want to do; you still have to tap and scroll and tap and scroll to get it done.

Maybe I’ll get used to Shortcuts programming. I hope so, as it’s the only game in town. My fear, though, is that it’ll be like AppleScript, a language I’ve been using for over 20 years and have never felt comfortable with.


  1. Had I been checking my email, I would have seen that Matthias Fichtner sent me a similar message before Tim did, and I would have credited him for the improved shortcut. Great minds think alike (and my mind wasn’t one of them).