Created
August 27, 2019 20:31
-
-
Save simonbs/1021a68b10d00a745bc57983537258e4 to your computer and use it in GitHub Desktop.
Appends text to a file. To be used with Shortcuts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-blue; icon-glyph: file-signature; | |
let text = args.shortcutParameter | |
let fm = FileManager.iCloud() | |
let filePath = args.fileURLs[0] | |
let content = fm.readString(filePath) | |
let newText = content + "\n" + text | |
fm.writeString(filePath, newText) | |
Script.complete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thank you for this example. Shouldn’t downloadFileFromiCloud be used before readString to make sure that the file is already stored locally? If so, could you enhance your example? At the moment I‘m struggling a little bit with this...An example would help a lot.
Thx a lot!
Mark