Shortcuts: export PDF from Numbers to specific iCloud folder, “file does not exist” error?

I’m trying to build a very simple Shortcut that saves exported PDFs from Apple Numbers to a specific folder in iCloud Drive. And it is indeed a subfolder of /Shortcuts.

When I run the Shortcuts, I get the error, “The file does not exist”, and below it uses the filename in a similar detailed message.

I have a very similar Shortcut to save PDFs from the web (to a different specified folder) that works fine. Is this something to do with exporting versus merely saving a file? Perhaps to Shortcuts, the exported file doesn’t “exist” until actually saved?

If so, is there a workaround for this?

I want to save the exported PDFs to a specific folder, and use the clipboard as the filename. But I’ll settle for merely being able to save the file to the specific folder with the default filename.

If I Export > PDF > Export > Share from Numbers, using the shortcut below saves the PDF into my Shortcuts/Temp directory with the filename on the clipboard.

Without seeing your shortcut it is difficult to tell if there is anything amiss with it that might explain your issue. Do always consider posting a link to your shortcut, even if it is not working, and even if it seems trivial; it may well still be of value in developing a better understanding.

Here’s the link to the Shortcut.

image

I made it as simple as possible to troubleshoot. I just added a trailing slash to the path, and ran it again. This time, it saved the file to the Shortcuts folder with the filename “invoices”.

I have other Shortcuts that will create the folders if they don’t exist, as it was in this case.

There is a pattern to these errors, but not sure why they are happening.

Is that it saved the PDF with a file name of “invoices” to the .../Shortcuts folder, or it saved the PDF with it’s original file name to the .../Shortcuts/invoices/ folder?


If the invoices folder exists, I would expect (and using your shortcut did) to get the PDF saved into the .../Shortcuts/invoices/ directory with its original file name; but with a.pdf file extension.


If the invoices folder does not exist, then the default behaviour takes over and that latter part of the path is converted into being the file name for the file. This is Shortcuts doing its best to help users who are not as familiar with file systems and programming. Again, this is the observed behaviour I see when running your shortcut when I remove the invoices directory.


That’s the pattern of behaviour I see so far, and that matches what I’ve seen with Shortcut for some time. However, I haven’t been able to reproduce the error “The file does not exist” in any of my tests with your shortcut.

By the way, did the shortcut I posted previously work for you and cover everything you wanted to do?

1 Like

You are correct, it was the lack of the folder existing that was causing the issue. What threw me off was in other shortcuts, I was sure I was able to get Shortcuts to create a non-existent folder, but that is seeming incorrect. I might be thinking about Hazel here.

Initially I assumed my problem was that there was no trailing slash, therefore indicating the end of the specified path was to be the filename, but adding the trailing slash did not change this (and in my opinion, it should — since the trailing slash explicitly implies a folder/directory).

The reason for the initial “file does not exist” was because my initial shortcut actually had more non-existent folders in the file path, and I had unwisely simplified my shortcut and examples for this post.

Thanks!