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