Help Creating Bookmark to Folder using Shortcuts Action

Hi everyone!
I’m fairly new to Scriptable/JavaScript in general, but so far it’s been very fun to learn! One thing I am having trouble understanding, however, is how to go about creating a bookmark to a folder from ios Shortcuts.
In particular, I would like to create a bookmark to a Readdle Documents 6 folder to save an item and save a file to said folder using the shortcut, but I am unsure of how to use the shortcuts action to create a bookmark. More specifically, how should I define which folder I want to access and how should I feed this to the shortcuts “create a file bookmark” action? Should I create a text file with the path to said folder and use this as the input to the shortcuts action? I’ve tried this, but have had no success yet:( If anyone could lend me a hand I would really appreciate it as I have always wanted a way ti automatically save a file from shortcuts! Thanks!

Are you trying to save a file from Shortcuts or a file from Scriptable?

Shortcuts can save files to any folder, but if you want it automatic, then it would need to be within the Shortcuts folder structure.

Scriptable can create file system bookmarks, but the bookmarks are for use in Scriptable (either standalone or via the Shortcuts calling); but that isn’t the same as making such a bookmark available for Shortcuts to us, only Scriptable when triggered from Shortcuts.

At least that’s my current understanding.

2 Likes

Hi I am trying to figure out how this works for my situation. I have a database.json file i created that lives in iCloud/Shortcuts/MPGTracker/database.json. I am creating a shortcut that asks a serious of questions and creates a dictionary that is then passed on to scriptable to calculate some values and concatenate the new dictionary (JSON) to the database array as a new value.

Do i need to use a file bookmark made in shortcuts for this to work in this fashion? Also what is the file that i put in the shortcut bookmark for scriptable because i don’t see it takes any input type.

If you are happy to navigate yourself to the file each time, no. If you want to automate it with no selection each time, then yes.

That’s covered in the on page information in the app for bookmarks. You need the FileManager path.

Take note that to use the bookmark in Shortcuts you should generate it in Shortcuts; as specified on the bookmarks settings page in Scriptable.

Hope that helps.

Ok that makes sense. However, how do you make bookmarks for files inside shortcuts folder? I am trying it and the shortcut crashes.

This worked for me just now.

If it does not work for you, try restarting your device.

doesn’t work and tried restarting already as well.

Noticiting that it can work for a pdf or another file but not json for bookmarking. It crashes shortcuts all the time when i run the shortcut.

I used the same shortcut to bookmark a JSON file, and there was no crash for me.

Could there be anything to where exactly you are storing the file or the file itself?

To test that, you could try reproducing my test above.

Example JSON Test

Location: //iCloud Drive/Test/Test JSON.json
Contents:

{"cyan":"#00ffff","limegreen":"#32cd32","indianred":"#cd5c5c","azure":"#f0ffff","lawngreen":"#7cfc00","papayawhip":"#ffefd5","violet":"#ee82ee","darkolivegreen":"#556b2f","yellowgreen":"#9acd32","darkgoldenrod":"#b8860b","peachpuff":"#ffdab9","dimgray":"#696969","lightsteelblue":"#b0c4de","powderblue":"#b0e0e6","dodgerblue":"#1e90ff","rebeccapurple":"#663399","royalblue":"#4169e1","saddlebrown":"#8b4513","lightgreen":"#90ee90","khaki":"#f0e68c","darkslateblue":"#483d8b","mintcream":"#f5fffa","black":"#000000","lightcoral":"#f08080","darkgreen":"#006400","crimson":"#dc143c","yellow":"#ffff00","lightsalmon":"#ffa07a","blue":"#0000ff","gray":"#808080","darkorchid":"#9932cc","olivedrab":"#6b8e23","darkorange":"#ff8c00","aliceblue":"#f0f8ff","mediumvioletred":"#c71585","orchid":"#da70d6","chartreuse":"#7fff00","white":"#ffffff","turquoise":"#40e0d0","darkgray":"#a9a9a9","aquamarine":"#7fffd4","pink":"#ffc0cb","bisque":"#ffe4c4","darkslategray":"#2f4f4f","sienna":"#a0522d","cadetblue":"#5f9ea0","lavenderblush":"#fff0f5","olive":"#808000","slategray":"#708090","wheat":"#f5deb3","cornsilk":"#fff8dc","lightblue":"#add8e6","purple":"#800080","lavender":"#e6e6fa","lemonchiffon":"#fffacd","slategrey":"#708090","blanchedalmond":"#ffebcd","deeppink":"#ff1493","firebrick":"#b22222","palegoldenrod":"#eee8aa","darkseagreen":"#8fbc8f","darkcyan":"#008b8b","linen":"#faf0e6","mediumorchid":"#ba55d3","palevioletred":"#db7093","green":"#008000","dimgrey":"#696969","lightcyan":"#e0ffff","midnightblue":"#191970","orange":"#ffa500","lightslategrey":"#778899","darkturquoise":"#00ced1","thistle":"#d8bfd8","salmon":"#fa8072","mediumblue":"#0000cd","aqua":"#00ffff","ghostwhite":"#f8f8ff","indigo":"#4b0082","floralwhite":"#fffaf0","maroon":"#800000","orangered":"#ff4500","lightpink":"#ffb6c1","fuchsia":"#ff00ff","gainsboro":"#dcdcdc","goldenrod":"#daa520","oldlace":"#fdf5e6","chocolate":"#d2691e","plum":"#dda0dd","snow":"#fffafa","seashell":"#fff5ee","darkred":"#8b0000","beige":"#f5f5dc","steelblue":"#4682b4","blueviolet":"#8a2be2","mediumaquamarine":"#66cdaa","cornflowerblue":"#6495ed","moccasin":"#ffe4b5","darkviolet":"#9400d3","sandybrown":"#f4a460","magenta":"#ff00ff","darkblue":"#00008b","darkslategrey":"#2f4f4f","lightyellow":"#ffffe0","navajowhite":"#ffdead","navy":"#000080","whitesmoke":"#f5f5f5","deepskyblue":"#00bfff","red":"#ff0000","greenyellow":"#adff2f","lightgray":"#d3d3d3","darkkhaki":"#bdb76b","lightslategray":"#778899","coral":"#ff7f50","palegreen":"#98fb98","seagreen":"#2e8b57","darksalmon":"#e9967a","lightgrey":"#d3d3d3","mediumturquoise":"#48d1cc","tan":"#d2b48c","ivory":"#fffff0","mediumslateblue":"#7b68ee","darkmagenta":"#8b008b","lightgoldenrodyellow":"#fafad2","peru":"#cd853f","silver":"#c0c0c0","darkgrey":"#a9a9a9","grey":"#808080","teal":"#008080","skyblue":"#87ceeb","burlywood":"#deb887","slateblue":"#6a5acd","mediumpurple":"#9370db","mediumseagreen":"#3cb371","lightskyblue":"#87cefa","springgreen":"#00ff7f","tomato":"#ff6347","lightseagreen":"#20b2aa","lime":"#00ff00","gold":"#ffd700","mediumspringgreen":"#00fa9a","antiquewhite":"#faebd7","mistyrose":"#ffe4e1","hotpink":"#ff69b4","brown":"#a52a2a","rosybrown":"#bc8f8f","forestgreen":"#228b22","honeydew":"#f0fff0","paleturquoise":"#afeeee"}

Failing that highlighting something, I guess it could be a variation in device/OS or something about your installation.

I had to wipe Shortcuts off all of my devices and drop all shortcuts to get sync working in i*OS13, and I never even used the betas; and I know that lots of people have had a variety of issues a wipe has resolved.

Hope that helps.

1 Like

let me run this. Thank you.

Is there a way I can just use the file bookmarks I create from scriptable itself and still run it automatically the shortcut?

1 Like

I’m not sure I quite follow your question.

If you mean can you create file bookmarks directly in Scriptable and then use them in Scriptable from Shortcuts, then the answer would be no. That’s as per the on page documentation.

If you mean can you create a file bookmark from Scriptable in Shortcuts in one shortcut, and then use that later in another Scriptable in Shortcuts script, then yes. As long as it is listed in the Siri & Shortcuts section within Scriptable, you can access it universally from Shortcuts.

If you mean something else, can you please explain?

What I mean is that I’m able to create a bookmark inside the scriptable app and it is labeled under APP not “Siri Shortcuts” section. I can’t seem to do a bookmark from under the Siri Shortcuts, for whatever reason. So trying to work with what works and still accomplish my shortcut. Does it make sense now? Sorry for the confusion.

Also if I wanted to delete shortcuts how do I backup my shortcuts as those aren’t backed up from iCloud I think.

That is what the Shortcut I posted above should do. Look back at the screen shots and you’ll see it being created in the correct section.

Shortcuts sync over iCloud and should be included in your standard backup routine. If you want to independently backup and restore shortcuts, take a look at this thread.

Your json worked, but after further troubleshooting, i am noticing what is the problem. The problem that I am facing is that my json file is a an array of json files. I fixed it! By doing {[{obj0}, {obj1}, … {objn}]} instead of [{obj0}, {obj1}, … {objn}], which i guess was improper json.

EDIT: nevermind, doing it this way {[{obj0}, {obj1}, … {objn}]} is not proper JSON as firefox and Jayson ios app don’t open the file. However, it was the only way that the shortcut worked to create a bookmark.

EDIT EDIT: i tried your file and when you add [] at the beginning and end then siri will crash. Try it and let me know.

EDIT EDIT EDIT: I forgot to add a key! so now it all works. I guess its improper JSON to start with an array, however, firefox and Jayson ios app still open a JSON file if its just an array, but Siri will crash if it doesn’t see the JSON file starting with a curly brace and a key then you have an array.

Well, as you noted in your third revision, since that wouldn’t be JSON, I’m not exactly surprised it would crash. The fact that the other apps are more lenient towards what sounds like malformed JSON isn’t exactly a great reason to use such JSON.

My understanding is that you should have, and hopefully now have, something like this:

{ "data" : [{obj0},{obj1},{objN}] }

Where {obj#} is a nested set of JSON.

1 Like

Yup that is exactly what i have now. I have never really worked with JSON much in terms of using it as a database for collecting stuff. Usually just program it as a variable in javascript and in python its different syntax. But glad it wasn’t something that was like a bug or more ambiguous.

Thank you very much for sticking with me to help me solve it!

1 Like

In Python it’s not JSON but rather a dictionary - with keys and values.

1 Like