Specifying a file Path in Get File action

The Get File action from Documents has an option to select a file when the action is run. If that option is turned off, I can specify a path however the beginning of the path is fixed at /Shortcuts. Since I can select other directories if I use the File Picker, is there a way to enter a path to one of those directories so that the action will run without manual intervention?

Can you specify which folder you wish to select a file from? :blush:

It sounds like you are talking about Shortcuts. Using that action you won’t be able to specify anything outside of iCloud without using the manual picker option. It’s a sandboxing constraint.

If you have access to Toolbox Pro or Scriptable, they both have file and folder bookmarks features that allow you to workaround the sandbox constraint.

As well as each app’s app documentation, if you search for “bookmark” on this forum, you’ll find further discussions and examples.

Hope that helps.

I have read what I could find on the forum and I’ve downloaded your script for creating a file bookmark and viewing the file but I’m afraid that hasn’t solved my problem. I want to be able to access a file belonging to another app (SQLIte) by way of a bookmark. The file is not on iCloud, it’s local. In scriptable I can create a bookmark to it but how do I use that bookmark in Shortcuts so as to pass that file to another action? I am guessing I need a js script that runs in a s Scriptable hortcut and fetches the file based on the bookmark.
If I have to create the bookmark from within Shortcuts (as opposed to Scriptable) then how to do that?

You don’t access it outside of Scriptable. You have to work with the file in Scriptable if you are using a Scriptable bookmark.

You do it programmatically. Within Shortcuts, run a Scriptable script that creates the bookmark. Then you’ll be able to access it in other Scriptable scripts run in any shortcut.

The Scriptable action “Create File Bookmark” has a file Parameter but the only options are Clipboard and Current Date. How do I select a file that is in another app to create the bookmark that I use in a Scriptable action to get the file contents to pass to another action?
(Your script creates a file on iCloud but I want to create a bookmark for one that already exists locally.

Pass it a file. When you use the manual picker option you can browse your file providers and pass that selected file in.

Ok, did that. The bookmark shows up in Scriptable. How do I now use that bookmark to get the file contents to pass to the next action which wants a file as a parameter? I tried taking the js code from your bookmark Shortcut for viewing the file contents but that shows no output (possible because it is an sqlite file).

I confirmed the content of the File bookmark by running the Get Existing Bookmark path Scriptable script from Shortcuts. However, I am still not able to read the file to pass it to the next action.

I think that the problem now is that the output of the Run Script with this inline script:

let fmExample = FileManager.iCloud();
let strFilePath = fmExample.bookmarkedPath(“Mybookmark”);
let strContents = fmExample.readString(strFilePath);

is not a file which is what the next action requires and I do not know how to make it conform.

My guess would be that you are not reading in any content.

It looks like you are using readString()to read the content of the SQLite database, but the SQLite file will be binary. readString() is for reading plain text content, not binary content.

To test this you could do one of the following:

  1. Do the read in Scriptable, and then try and write out “CONTENT=” followed by the first few characters read in to a temporary text file and then manually view that file in the Files app (or a text editor app). Confirm if the file contains “CONTENT=” and additional content.
  2. Try reading a known text file instead of the SQLite file and see if that gets you any content coming through.

I will try that although I suspect you are correct in that a Show Output action after the Scriptable script shows a box with no content. If that is the problem, is there a change to the script above that would read it and pass it as a file?

Actually, now that I think about it, I can’t do the read from Scriptable can I? I thought that the bookmark had to used from Shortcuts. Indeed Scriptable says it can’t find the bookmark when I run it in the app.

You would need to check *in* the Scriptable script. Not in Shortcuts, otherwise you would not be checking where the read is occurring.

  • If you create a Scriptable bookmark in the Scriptable app, it is accessible only in Scriptable.
  • If you create a Scriptable bookmark in Scriptable via Shortcuts, it is accessible only when running Scriptable via Shortcuts.

I am able to read a text file using a bookmark from within Scriptable. However, if I try the same test with the sqlite file, there is no output. So, I am back to the question of how to read (a binary) file and return it in an action.

Scriptable doesn’t currently have a binary file reading function as far as I can tell. I think you would have to flag it for Simon’s consideration; he’s certainly not against expanding what file capabilities Scriptable can offer.

Just ensure that you also know how you would process the SQLite file once you have it.

Thanks. I can deal with the SQLite file using the excellent SQLite app. I have no trouble getting files from SFTP servers or elsewhere and feeding them to SQLite. My problem remains being able to get to a local file from the Shortcut action.

If you really just want to shunt the file to another app rather than processing it within Shortcuts, consider Toolbox Pro’s bookmarking instead. Rather than reading file content it’ll just grab the file.


1 Like

Yes, I think that Toolbox Pro is the easiest way to do this. I wonder if Shortcuts in IOS 14 includes new actions that might help. Have you looked at the beta? I know that Apple has done a lot of work on enhancing Shortcuts and encouraging developers to use it.

I don’t think there’s anything that would help in this instance.

I’ve been following its progress but not using it. Still too many issues for me to risk it on my devices - I don’t have any secondary devices.