Skip to content

Instantly share code, notes, and snippets.

@gbcosgrove
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbcosgrove/d84ec4e53feacc56e1a5 to your computer and use it in GitHub Desktop.
Save gbcosgrove/d84ec4e53feacc56e1a5 to your computer and use it in GitHub Desktop.
Batch Append Notes in Omnifocus 2
JsOsaDAS1.001.00bplist00ÑVscript_8/**
*
*
* @author Greg Cosgrove
* Special thanks to Brandon Pittman whose OmniFocusLibrary.js I used as a template for this script
*/
var app = Application('omnifocus');
app.includeStandardAdditions = true;
var current = Application.currentApplication();
current.includeStandardAdditions = true;
var doc = app.defaultDocument;
function selected() {
return app.windows[0].content.selectedTrees.value();
}
function appendNote(tasks, tags) {
tasks.forEach(function(task) {
var oldTags = task.note();
task.note = oldTags + " " + tags;
})
alert("Success!");
}
function alert(text, informationalText) {
var options = { }
if (informationalText) options.message = informationalText
app.displayAlert(text, options)
}
function prompt(text, defaultAnswer) {
var options = { defaultAnswer: defaultAnswer || '' }
try {
return app.displayDialog(text, options).textReturned
} catch (e) {
return null
}
}
var targetTasks = selected();
var newTags = prompt("What Tags?", "")
appendNote(targetTasks, newTags);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment