Task Linked Files

A task Linked File is a file reference in URL format for a file that is linked to a task. Omni Automation in OmniFocus (v3.8+) provides the ability to add and remove file links to/from tasks.

File links are often used in place of task attachments in order to minimize the size of the data added to the OmniFocus database. The inclusion of large files in a synced OmniFocus database can compromise performance across devices.

Task Linked File Properties

There is one property regarding Linked Files for the Task class:

Task Linked Files Functions

The functions of the Task class dealing with the management of file links.

Adding File Links

Task File Links are instances of the URL class with each instance representing a file.

The following example plug-in demonstrates how create File Link instances from chosen files and add them to a selected task.

Add Chosen Files to Task as Links
  

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automaator", "identifier": "com.omni-automation.of.add-linked-files-to-task", "version": "1.1", "description": "This action will add chosen files as file links to the selected task.", "label": "Add File Links to Task", "shortLabel": "Add File Links", "paletteLabel": "Add File Links", "image": "doc.on.doc" }*/ (() => { const action = new PlugIn.Action(async function(selection, sender){ task = selection.tasks[0] picker = new FilePicker() picker.folders = false picker.multiple = true picker.types = null // any file type urlsArray = await picker.show() urlsArray.forEach(url =>{ task.addLinkedFileURL(url) }) }); action.validate = function(selection, sender){ return (selection.tasks.length === 1) }; return action; })();

Deleting File Links

Should you wish to remove file links from their assigned task, Omni Automation provides two mechanisms for deleting existing file links:

Deleting All File Links of Selected Tasks
 

tasks = document.windows[0].selection.tasks tasks.forEach(task =>{ urls = task.linkedFileURLs console.log(urls) urls.forEach(url => { task.removeLinkedFileWithURL(url) }) })