Thanks for sharing!
After copy and pasting the script, it first did not work, but then I noticed that the single and double quotes in the script got mangled when the code was posted to the forum. Here is a fixed version for anyone else interested in trying this out:
let bookmarkName = "Obsidian"
let fm = FileManager.iCloud()
if(fm.bookmarkExists(bookmarkName)) {
let folder = fm.bookmarkedPath(bookmarkName)
let files = fm.listContents(folder)
files.forEach(f)
function f(name) {
let filePath = fm.joinPath(folder, name)
fm.downloadFileFromiCloud(filePath)
}
return ("Bookmark '" + bookmarkName + "' found\n\n" + "Files found:\n" + files)
} else {
return "Bookmark '" + bookmarkName + "' not found"
}
Script.complete()
I just got it working, so I don’t have a sense yet, to what extent it will actually reduce/eliminate the “Waiting for iCloud to synchronize” wait times for me, but I don’t see why it wouldn’t. I’m very glad I found this thread.
For anyone else trying this out:
The script looks like it’s supposed to display either a “Bookmark ‘Obsidian’ not found” message or a list of the files that it found. Those messages are only shown, however, when you run the script from inside the Shortcuts app (i.e., by pressing the little blue “play icon” button in the bottom right while editing the Run inline script action). When the actual automation is triggered, you only get a generic “Running your automation” notification, which is preferable anyway, because the point of the script is only to trigger an iCloud sync for the Obsidian folder.
Mission accomplished! 