Skip to content

Instantly share code, notes, and snippets.

@gbcosgrove
Created May 23, 2015 04:52
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/f307117f71d210d88bc2 to your computer and use it in GitHub Desktop.
Save gbcosgrove/f307117f71d210d88bc2 to your computer and use it in GitHub Desktop.
AppleScript for batch adding notes to tasks in OmniFocus
/**
*
*
* @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 = 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