Plug-In: Duplicate Selected Projects to New Folder
Duplicates the selected projects to a new folder and sets the status of the duplicated projects to Active. Good for use with stored “On-Hold” projects!
Return to: OmniFocus Plug-In Collection
Duplicate Selected Projects to New Folder
/*{"type": "action","targets": ["omnifocus"],"author": "Otto Automator","identifier": "com.omni-automation.of.duplicate-project-to-new-folder","version": "1.2","description": "Duplicates the selected projects to a new folder and sets the status of the duplicated projects to Active.","label": "Duplicate to New Folder","shortLabel": "Duplicate to New Folder","paletteLabel": "Duplicate to New Folder","image": "plus.rectangle.on.folder"}*/(() => {const action = new PlugIn.Action(async function(selection, sender){items = selection.projectstextInputField = new Form.Field.String("folderName","Folder Title",null)statusMenuField = new Form.Field.Option("statusIndex","Project Status",[0,1],["Active", "On-Hold"],0)inputForm = new Form()inputForm.addField(textInputField)inputForm.addField(statusMenuField)inputForm.validate = function(formObject){var textValue = formObject.values['folderName']if(!textValue){return false}return true}formObject = await inputForm.show("Name for folder:","Continue")folderName = formObject.values["folderName"]folder = new Folder(folderName)statusIndex = formObject.values["statusIndex"]statusType = [Project.Status.Active, Project.Status.OnHold][statusIndex]duplicatedItems = duplicateSections(items, folder.beginning)duplicatedItems.forEach(item => item.status = statusType)folderID = folder.id.primaryKeyURL.fromString("omnifocus:///folder/" + folderID).open()});action.validate = function(selection, sender){return (selection.projects.length > 0)};return action;})();