Receiving files from a script launched via an extension

I’m trying to accept one or more files passed in via an extension to a Scriptable script. I’m able to receive a path to the file via args.fileUrls, but the name of the file is always a UUID-like file name.

Is there a way to retrieve the actual file name of the shared file?

It may be that Scriptable renames the file in some occasions to avoid collisions with existing files. Shouldn’t be a problem in the case you describe. I’ll look into it.

I’ve tried two different scenarios:

  1. Export pdf from iaWriter and then share to Scriptable
  2. Select file in iCloud Drive (outside of Scriptables folder) from Files app and share to Scriptable.

Both files (with different file names) had the same results.

I’ve done a handful of tests using the script below. It’s been across a variety of storage providers (including of course iCloud), folder structure depths and file formats. Each has given me the expected filename in the last URL component.

Maybe you could have a quick test and see if that holds true for you too?

alMsg = new Alert();
alMsg.title = "First Received Filename";
alMsg.message = args.fileURLs[0];

//Copy URL to clipboard and display in an alert

Example result from iCloud (Keynote’s folder)

Example result from Working Copy.

1 Like

My code was a bit different, but I grabbed your code to try - same results (exporting a PDF generated in iaWriter):

I got a similar result with sharing a file from the Files app (from the Numbers directory) but I can only post one image given my account status.

Forgot to mention - in case it’s relevant, I’m running build 1.3.2 (86).

Same Scriptable build version for me, but I see a filename for a Numbers file shared from Files.

On a hunch, I just checked the “Always Run in App” setting. I have this turned on for my script (as I was intending to leverage File Bookmarks). I set that automatically when I created a script with your code. Once I turned the setting off and ran the script only in an extension, it works as expected. FYI @simonbs

1 Like

Just in case it is of use, here’s a quick set of test results using my script above on a common file being shared from Files.

RUN 1: Always Run in App ENABLED


RUN 2: Always Run in App ENABLED


RUN 3: Always Run in App DISABLED

  • It definitely supports the idea of the generation of a transient URL, as it varies between runs.
  • There are significant differences in the structure of the URL path (apart from a small chunk) when the option is enabled/disabled.
1 Like

Thanks for looking into this. I just wanted to lte you know that this is fixed in the next update. Files will keep their file names, even when “Always Run in App” is enabled. Inputs that does not have names by itself, e.g. photos, will still have generated file names.

I’m not sure how much value this blurry GIF provides but nonetheless it shows that the issue have been fixed.

Once again thanks for taking your time to provide feedback and look into the issue.


1 Like