SkillAgentSearch skills...

Templates

Templates Applescript for OmniFocus.

Install / Use

/learn @lemonmade/Templates
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Templates.scpt

Important Note

I no longer actively maintain this script, and haven't for some time. Further, I no longer use OmniFocus (nothing against it, my needs/ tastes just changed). You might be interested in this fork instead, which is more actively being worked on.

Screencast

If you need help understanding the features of this script, you can watch a video of the script in action to get you up to speed.

Why I Built This Script

OmniFocus is an incredible piece of software. I and countless others rely on it every day to manage increasingly hectic lives and complex, multi-facetted projects. A central tenet of "good" productivity tools (as opposed to those we simply indulge in for their own sake, the "productivity porn") is that they reduce friction. This script is an effort to reduce one of the largest sources of friction remaining in my OmniFocus setup: maintaining and creating projects that don't recur on even intervals, but occur frequently enough that their planning and capture becomes a time sink. The script allows you to create templates as simple or complex as you need them to be, and to quickly create instances of those templates so you can get back to what's important.

Script Basics

You need a few things before the script will work as intended. The script looks for a folder that contains the word "Template" in the name, and assumes that this is the folder from which you want to select template projects. This folder can be Dropped, and the actual template projects can be On Hold (the script will automatically switch the new template instances to Active). If it doesn't find an obvious template folder, it will ask you which folder to use.

When the script runs, it does a number of things. It will first ask you which project inside the template folder you would like to create a new instance of, then ask in which folder you would like to put the new project instance. If there are any variables or "ask" statements (discussed later) the script will prompt you to provide any additional input required. If you have Growl installed, a Growl alert will come up when you start the script and when you finish it. The alert indicating the end of the script can be clicked to quickly show you the new instance of your template project.

On first run, the script will ask you to choose a variable symbol and, if it detects that you have projects already using Curt Clifton's OmniFocus template syntax (which were a big inspiration for this project), it will offer to convert these to this script's syntax.

Script Components

Variables

You can use variables in your script to have the script prompt you for a string that will be used in multiple places of the new template instance. For example, a template for contacting someone may use a person's name for a number of tasks/ notes/ context names, and the name to use may change for each project instance. This is an ideal time to use a basic variable. Note that all variables are case-insensitive.

Basic Variables are the most important part of the script. By default, you declare a basic variable by writing that variables name, preceeded by the "$" sign, anywhere in the template project's note (on the first run the script will prompt you to select an alternate variable symbol, if you wish). Variable names can contain spaces and you can have as many as you wish (though must all be in the same paragraph of the project's note; for example, $variable1 $another variable $the last variable would declare three variables for use in the script). Once these variables are declared, you can use them almost anywhere: the project note, project name, task name, task note, and/or task context. When the script is run, it will detect the variables, ask you what you would like to replace each with, and then do a search and replace through the entire project based on your input.

Example: You declare $person $subject in your project note. One of the task names is "Email $person about $subject", and when prompted you choose to replace "$person" with "John" and "$subject" with "TPS Report". In the new project instance, the task will have the name "Email John about TPS Report".

Choose Variables are a special kind of variable that allow you define a list of options from which you will choose when creating a new instance of the project. You declare these along with your basic variables (that is, using the same variable symbol and in the same paragraph as your basic variables), but use the following adjusted notation: $variableName {option 1, option 2, option 3}. Upon creating a new instance of the project, you will be asked which of these options to replace the variable $variableName with.

Date Variables are another special variable that you give a relative or absolute date as input. You declare these just like basic variables, but their name must start with the word "date" (for example, $date of module 1 or $date-stage1). When prompted for input, you can use any of the relative or absolute date strings you can normally use with OmniFocus; things like "19:00", "1d" (1 day), "3w 4d 2pm" (3 weeks and 4 days at 2:00PM), "sun" (next Sunday), "Feb 28", and "February 28" will all work. The "short date" format you have specified in the Language and Region preference pane will also work as an absolute date. The order of the year, month and date are all that matter, and the year, month and date can the be stated with or without leading ones and with any of the following seperators: ".", "/", and "-". So, if your short date format is YY/MM/DD, all of the following would represent January 31, 2014: "14.01.31", "2014/01/31", and "01-31". These date variables can then be used in place of basic variables (that is, as text) or, more interestingly, in assigning start and due dates (see below).

When using date variables for inserting the date in task notes/ names, you can specify a custom format in which the date will be inserted by changing the dateFormat property within the script. The default will be to insert the date in the format "June 17, 2013". You can change the way in which the year, month, day, and/or weekday will be displayed, as well as what other text you would like to have in the date. For the details on setting up your own custom format, see the comments included below the dateFormat property at the top of the script.

"Today" Variable is a special date variable. A variable declared as "Today" will automatically be assigned today's date, which can then be used in the same places as any other variable.

Start and Due Dates

The script can assign due dates to any subset of tasks in the template projects, or to the project itself. Start dates are set using the phrase start: in a new paragraph of the project/ task's note, while due dates are set using due: . You then include one of the following date declaration types:

Relative to Today: stating a relative date after the start/ due statement will set the task's start/ due to today (at 12:00AM) plus the relative date indicated. For example, if today is January 1 and you create a new instance of a template that has a task whose note contains start: 1w on a new line, the new instance of the project will have a start date of January 8. If it also has due: 1w 2d 2pm on another new line, the task's due date will be January 10 at 2:00PM.

Relative to Project: for all tasks inside a template project, you can set the start/due date relative to those of the project. To do so, you use the keywork project and the math you want to perform. So, for example, start: project + 3d will set the start date of that task to 3 days after the start date of the project.

Using Date Variables: if you declared date variables in the project note, you can use them in any task or project start/ due date (with additional date math, if you wish). For example, start: $dateVariable will set the start date to $dateVariable (if it is declared), while due: $dateVariable + 2w will set the due date to the date of $dateVariable plus 2 weeks.

ask: the last option is to use the keyword ask. This will get the script to prompt you for the date. For example, setting the note of the project to have both start: ask and due: ask (on separate lines) will make the script prompt you for a start and a due date (using the same relative/ absolute dates as before).

The script will try to be smart about telling you that you have a mismatch in your project and task due/ start dates (for example, a task has a due date after that of the project, or has a due date in the past).

Default Folder

You can select a default folder into which to place new instances of a template project. To do so, place the following in a new paragraph of the project note: >>> defaultFolder, where you replace defaultFolder with the exact name of the target folder. For example, >>> Work will place new instances of that template project in the folder whose name is "Work". You can specify a subfolder to place it in as well, if you have a more complex folder structure: this is done using the symbol > to denote a subfolder. For example, >>> Work > Job1 would place all new instances of the project in the Job1 folder under the Work folder.

Conditionals

The script can complete or delete tasks or task groups within the projects contingently (i.e., using an if/else statement). In order to use this feature, you include a conditional statement in the note of the desired tasks/ task groups in the following format: @if $variableName [<=, >=, ==, !=, >, <] comparison then [complete, delete]. The entire statement must be all by itself on a new line in the task note for the conditional statement to work.

The operators are self-explanatory, but are explained here in case you are not familiar with the

View on GitHub
GitHub Stars278
CategoryDevelopment
Updated18d ago
Forks50

Languages

AppleScript

Security Score

95/100

Audited on Mar 18, 2026

No findings