I am trying to understand how this code from FSShortcuts works.
//Create a bookmark for a file object passed directly from the Shortcuts app
var fm = FileManager.iCloud()
// Get the file parameter from Shortcuts
var name = args.shortcutParameter
// Get the file type parameter from Shortcuts
var bookmarkType = args.plainTexts[0]
var file = fm.bookmarkedPath(name)
// Output the file path as a dictionary to force plain text
Script.setShortcutOutput({"path":file, "name":name, "type":bookmarkType})
Where does the bookmark type get it’s value?
So far I have created a Bookmark in Scriptable called Batman which is in the directory iCloud/Batman.
It should be getting it from the item passed in from Shortcuts as per the comments. If you look at the Shortcut rather than the JavaScript, you’ll see file bookmark creation passes in one file argument, but folder creation passes in a dictionary. Try bookmarking a folder and see if that gets you a type.
If I were using Scriptable for file bookmarks, and wanting more file/folder information, I’d try and process it in Scriptable. If I wanted to focus on working with it in Shortcuts, I’d use Toolbox Pro’s bookmarks functionality.
Focusing on Scriptable, if I add a folder bookmark for a folder like this, containing files and folders (which contain further files and/or sub-folders themselves)…
So…would it be possible to programmatically create a set of arguments on a Mac (with say an Alfred file action) and then pass them to Scriptable to create the bookmarks?
Unless Scriptable gets updated to install on a Mac it would make it a lot harder. I wouldn’t say impossible. As Far as I’m aware Alfred is a MacOS app, Shortcuts will be included in the next MacOS release but you’re still limited without Scriptable.
I’ve personally not seen that and I definitely heard pundits discussing the contrary position during WWDC. I’ve done a few quick web searches and nothing definitive has shown up. But absence doesn’t constitute proof - it could well be I’ve missed the news somehow.
I’ve been wondering how Shortcuts might play on an Apple Silicon-based Mac, but it would need to be part of Big Sur as it is an OS-level application since transitioning from Workflow. But I’ve not seen anything confirm that it would be an option.
Okay. I guess sometimes it may be easier to produce a list on a Mac if you already have something in place, but I would imagine you could produce the same on the mobile device anyway.
Just remember that if you do take this approach that you also need to change the initial part of the paths produced as that differs between macOS and i*OS. On Mac the library lives in your home directory whereas on the iPhone and iPad it lives off the root in /private/var/mobile.