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 attachments.

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.

Deleting File Links

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

var tasks = document.windows[0].selection.tasks tasks.forEach(task =>{ var urls = task.linkedFileURLs console.log(urls) urls.forEach(url => { task.removeLinkedFileWithURL(url) }) })
omnifocus://localhost/omnijs-run?script=try%7Bvar%20tasks%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Etasks%0Atasks%2EforEach%28task%20%3D%3E%7B%0A%09var%20urls%20%3D%20task%2ElinkedFileURLs%0A%09urls%2EforEach%28url%20%3D%3E%20%7B%0A%09%09task%2EremoveLinkedFileWithURL%28url%29%0A%09%7D%29%0A%7D%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D

DISCLAIMER