Plug-In: Note to File
This action will save the note text of the selected task to a file. On macOS, the option to open the created file will be presented after the export has completed.
NOTE: See the Data section for a plug-in to save clipboard RTF content to file.
Return to: OmniFocus Plug-In Collection
Note to File
/*{"type": "action","targets": ["omnifocus"],"author": "Otto Automator","identifier": "com.omni-automation.of.note-to-file","version": "1.1","description": "This action will save the note text of the selected task to a plain text file.","label": "Note to File","shortLabel": "Note to File","paletteLabel": "Note to File","image": "square.and.pencil.circle.fill"}*/(() => {const action = new PlugIn.Action(async function(selection, sender){try {task = selection.tasks[0]textToWrite = task.noteif(textToWrite === ""){alertMsg = "The note of the selected task contains no text."Alert("Missing Data", alertMsg).show()} else {textDataObj = Data.fromString(textToWrite)textFileName = task.name + " note.txt"wrapper = FileWrapper.withContents(textFileName, textDataObj)urlObj = await new FileSaver().show(wrapper)console.log(urlObj.string)if(Device.current.mac){alertTitle = "File Created"alertMsg = "Open the file?"alert = new Alert(alertTitle, alertMsg)alert.addOption("Open")alert.addOption("Skip")alert.show(function(result){if (result == 0){urlObj.open()}})}}}catch(err){if(!err.causedByUserCancelling){new Alert(err.namer, err.message).show()}}});action.validate = function(selection, sender){return (selection.tasks.length === 1)};return action;})();