Return to shortcuts

Hi everybody

Anyone know a better way to return to shortcuts app that the one shown in this script:

let file = args.shortcutParameter
let name = args.plainTexts
let fm = FileManager.iCloud()
let path = fm.bookmarkedPath(“Documents_VLC”)
let final = path+"/"+name+".mp4"
fm.copy(file,final)
Script.setShortcutOutput(name)
Safari.open(‘shortcuts:///’)

My script receive a video from a shortcut and copy it to a bookmarked folder. It’s works but there is two issues that bother me:

The first issue is that, even if the script works and returns me to the shortcut, I cannot pass any variable/data back to the shortcut.

The second issue is that the script only works to return to the shortcut if the shortcut is run from the shortcuts app. If I try to work it from the “share sheet” its return to the shortcuts main page but not the running shortcut. I manage to make it work modifying the last line of my script to:

Safari.open(‘https://google.es’)

Which make me return to the app where all begun (Safari) I prefer to return to a blank tab or similar but my newbie knowledge just lead me to that.

Any ideas? I ask the same thing in reddit but no solution yet

Thanks in advance

Can you run your script in Shortcuts as an inline script so that you don’t have to bounce back and forth between the two apps?

Nope. Bookmarks doesn’t works with inline script. Thanks

When you say “Bookmarks doesn’t works with inline script”, what aspect of it isn’t working?

As an example, if I have a Calca file (text based file containing calculation details for the Calca app) bookmarked by Shortcuts as “Calc2”.

Then I run an inline Scriptable script in Shortcuts that references this bookmark, I am able to return the file contents.

Ohh… I am so fool…

I didn’t see that to work in shortcuts , the file bookmark shall be created using the Create file bookmark action in shortcuts

I don’t know how to do it for my purposes, Because I want to copy a file into an internal folder in VLC app, but I will try.

Any thoughts?

Have you taken a look at the shortcut I posted yesterday as an example for someone on how to create bookmarks for use in Shortcuts? As long as you have a consistent file name, one bookmark should suffice indefinitely.

Yes, but It works for folders? I can add that type of bookmarks to a folder?

Frustratingly, Shortcuts doesn’t deal with folder selection (an interesting read that references this) for this; another reason I was noting a consistent, singular file name above.

If that’s a critical aspect, then the use of Shortcuts may well need to be reduced. :frowning:

Maybe you can bookmark a folder within Shortcuts like this (I can’t test it, I don’t have iOS 13):

  • Run inline script (Scriptable)
    return await DocumentPicker.open(["public.folder"])
    
    Show while running: on
  • Set Filename
    Input: previous action
    Name: previous action
  • Bookmark path (Scriptable)
    Input: previous action

Got this just running the inline script.

In Shortcuts.

Passing back to Scriptable; I’m assuming you meant Run in App rather than Show When Run.

image

Whoops, I overlooked that it expected an array… Thanks!

I’ve fixed the code above.

No, I’ve meant Show When Run to display the document picker. Maybe it is also displayed without that option?

This one’s more what I actually expected, which is why I thought maybe a run in on might be what you were going for,

Well, haven’t expected this, but does it work with Run in app?

Many thanks for testing!

No, I did try that and a few variations. I could get it to show the document picker in app, show the selected folder path via an alert, but then it always got stuck returning to Shortcuts and never returned anything.

1 Like