Skip to content

Instantly share code, notes, and snippets.

@simonbs
Created August 27, 2019 20:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save simonbs/1021a68b10d00a745bc57983537258e4 to your computer and use it in GitHub Desktop.
Save simonbs/1021a68b10d00a745bc57983537258e4 to your computer and use it in GitHub Desktop.
Appends text to a file. To be used with Shortcuts.
// 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()
@bestmacfly
Copy link

bestmacfly commented Oct 31, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment