-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deadlines.applescript
81 lines (41 loc) · 1.88 KB
/
Deadlines.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
set includeStartDate to true
set includeEndDate to false
(*
Separate user settings from rest of the script
*)
use application "OmniFocus"
use scripting additions
tell application "OmniOutliner"
if version ³ 5 then
set template to ((path to application support from user domain as string) & "The Omni Group:OmniOutliner:Pro Templates:" & "Blank.otemplate:") --- template path for OO5
else
set template to ((path to application support from user domain as string) & "The Omni Group:OmniOutliner:Templates:" & "Blank.oo3template:") --- template for OO3 or OO4
end if
set currentDate to current date
activate
open template
tell front document
if includeStartDate is false then
set currentDate to currentDate + (1 * days)
end if
set title of second column to "Project Name"
make new column with properties {title:"Days Left", column type:numeric, column format:{id:"no-thousands-no-decimal"}, sort order:ascending, alignment:center}
repeat with thisProject in (flattened projects of default document whose status is active status and due date is not missing value)
if defer date of thisProject ² currentDate then
if text of second cell of first row is equal to "" then
set newRow to first row
else
set newRow to make new row at end of (parent of last row)
end if
set text of second cell of newRow to name of thisProject
set value of attribute named "link" of style of text of second cell of newRow to "omnifocus:///task/" & id of thisProject
set dueDate to due date of thisProject
if includeEndDate is false then
set dueDate to dueDate - (1 * days)
end if
set timeLeft to (dueDate - currentDate) / 3600 / 24 as integer
set value of third cell of newRow to timeLeft
end if
end repeat
end tell
end tell