Help passing data in and out of MacOS Shortcuts Applescript

Hi folks,

I would like a little help understanding how to pass data, basically a dictionary, into an AppleScript for search and replace in a Pages document.

The Shortcut Applescript module seems to have some way to pass input/data in and out - but the documentation on how to use it seems to be non-existent. Maybe it’s obvious, and I just don’t get it as a newcomer to AppleScript. But some guidens on how to go about it would be very greatly appreciated.

Here’s the info for the shortcut action.


It notes “Files” as the input to the script, but it does accept text, so you could coerce your dictionary into a JSON format and pass that in. But then you would have to try and pick apart the text to get the elements you want in a usable format.

I tried just passing in a string of comma separated parameters to the action, and using string delimiters to split the string. However, while this works in my script editor, Shortcuts just kept giving me the whole list as one item. That feels pretty buggy, so I would be tempted to try using an osascript call to a script held outside of Shortcuts that I can test independently.

Expand for the Details

If I run this script in my script editor.


I get …


… followed by …


When I do the same thing, but using Shortcuts to pass the content into the action like this.


I get …


… followed by …


Which seem to be different behaviours given I copied and pasted the core code (just the “on” varies to allow me to test) between the two apps.

As for getting data back, a return seems to do the job just fine.


I am not sure how accurate the result variable types are as I’m not quite sure how dictionaries would factor in to AppleScript. See my note on lists and object properties being the closest match I can think of to dictionaries in the discussion of episode #86 (third section of the post).