Plug-In: Clipboard Objects to Markdown Links
This plug-in uses the Pasteboard class functions to convert the OmniFocus objects currently copied to the clipboard, into a series of markdown text links, replacing the current clipboard contents with the markdown text.
To use the plug-in, copy the target OmniFocus objects (folders, projects, tasks, or tags) to the clipboard and run the plug-in. The contents of the clipboard will be replaced with links to the objects in markdown format:

Return to: OmniFocus Plug-In Collection
Clipboard Objects to Markdown Links
/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Otto Automator",
"identifier": "com.omni-automation.of.pasteboard-objects-to-markdown-links",
"version": "1.0",
"description": "This plug-in converts the OmniFocus objects currently copied to the clipboard, into a series of markdown text links, replacing the current clipboard contents with the markdown text.",
"label": "Clipboard Objects to Markdown Links",
"shortLabel": "Markdown Links"
}*/
(() => {
var action = new PlugIn.Action(function(selection, sender){
// action code
// selection options: tasks, projects, folders, tags, allObjects
if (Pasteboard.general.hasURLs){
var links = Pasteboard.general.URLs
var markdownText = ""
var linkCount = links.length - 1
links.forEach((link,index) => {
var linkStr = link.string
var id = linkStr.substring(linkStr.lastIndexOf('/') + 1)
if (index === linkCount){
var endOfLine = ""
} else {
var endOfLine = "\n"
}
if(Folder.byIdentifier(id)){
var fldr = Folder.byIdentifier(id)
var markdownLink = `[FOLDER: ${fldr.name}](${linkStr})`
markdownText += markdownLink + endOfLine
} else if (Tag.byIdentifier(id)){
var tag = Tag.byIdentifier(id)
var markdownLink = `[TAG: ${tag.name}](${linkStr})`
markdownText += markdownLink + endOfLine
} else if (Project.byIdentifier(id)){
var project = Project.byIdentifier(id)
var markdownLink = `[PROJECT: ${project.name}](${linkStr})`
markdownText += markdownLink + endOfLine
} else if (Task.byIdentifier(id)){
var task = Task.byIdentifier(id)
var markdownLink = `[TASK: ${task.name}](${linkStr})`
markdownText += markdownLink + endOfLine
} else {
console.warn("Unknown", linkStr)
}
})
console.log(markdownText)
Pasteboard.general.string = markdownText
new Alert("COMPLETED","Markdown is on the clipboard.").show()
} else {
var alertTitle = "MISSING RESOURCE"
var alertMessage = "No OmniFocus objects have been copied to the clipboard."
new Alert(alertTitle,alertMessage).show()
}
});
action.validate = function(selection, sender){
// validation code
return true
};
return action;
})();