Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oneechan69

macrumors 6502
Original poster
Mar 29, 2022
264
31
US
On Mac and PC I can use file:/// URLs to open files on the device. Does iOS support that or have an equivalent?
 
I don’t think it’s supported natively, but you should be able to do that using the Shortcuts app.
 
I would prefer not to have to create a shortcut for every file I'd want to launch.
 
The shortcut could take the file name and path as an input, so you’d only need one.
 
Ditto Shortcut.

But… not simple (from my experience) and depends on what you want to do with the file.

Big problem that I’ve run into and have not dug into seeing if some way to do this in a general way is that the “Get File from Folder” action‘s first parameter seems to need a Folder (passed as a Shortcut Input) object or be hard coded to a specific folder (ie pre-selected). So at minimum, need to see if prefix of the pathname is “iCloud Drive” or “On My iPhone” (or On My iPad). So if statement: if iCloud, call one Get File, otherwise call Get File rooted at On My.

Attached is a simple example, would need to pass the parsed/formatted remainder of the pathname via a variable.

Here’s the Apple man page on how to create a URL to call a Shortcut and pass data to it. Noticed there is a typo in the example: URL has the wrong Shortcut name vs one in the description of the example.

 

Attachments

  • CB376874-63AF-438F-A884-2BBF1CD43EB8.jpeg
    CB376874-63AF-438F-A884-2BBF1CD43EB8.jpeg
    436.3 KB · Views: 139
  • Like
Reactions: max2
@Morac Yeah you should show how to make a shortcut that takes the file name and path input, and how it work well no matter which values u give it (as long as they're valid).
 
@Morac Yeah you should show how to make a shortcut that takes the file name and path input, and how it work well no matter which values u give it (as long as they're valid).
This is a simplified version that takes the name of the file (or part of the name) as the Shortcut input and opens the file app and searches for that file. If there is no input it will use the clipboard. At that point you can just tap the file to open it.

E5EEA995-4A6A-43B8-AB05-D3ACEB3A7726.png


If you want the file to open automatically you can use the a combination of scripting to and the “Open File” action to open the file, but as NoBoMac mentioned that gets complicated as you’d need to specify the entire path to the file as the input and specify where in Files it lives. The searching method above is much simpler.
 
While I could use this, is isn't what I was looking for. I want to be enter in a specific path and for iOS to go to it. This just searches for the file, but what happens if I have two files with the same name but in different paths? It might open the file I don't want.
 
It’s possible to write a Shortcut to do that, but it’s a lot harder and I don’t have the time to do that. The one I wrote will search for the file. If there’s 2 of them, you can tap on the one you want. It’s an extra step, but I’m not sure what your use case for all this is.

On a side note, there is also an app Scriptable which could probably do what you want more easily. It can be integrated into Shortcuts.

 
It’s possible to write a Shortcut to do that, but it’s a lot harder and I don’t have the time to do that. The one I wrote will search for the file. If there’s 2 of them, you can tap on the one you want. It’s an extra step, but I’m not sure what your use case for all this is.

On a side note, there is also an app Scriptable which could probably do what you want more easily. It can be integrated into Shortcuts.

Actually I could do that! I could create bookmarks in the app for specific directories, and make a script take a URL with an argument for the file path to open. However, I thought about it and decided I want to want to spent 30-60 mins figuring that out when I could quickly create a shortcut. Maybe I would if I had more files I wanted to open. Thanks anyway.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.