-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAuto Tags Script.applescript
More file actions
86 lines (63 loc) · 2.19 KB
/
Auto Tags Script.applescript
File metadata and controls
86 lines (63 loc) · 2.19 KB
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
82
83
84
85
86
on hazelProcessFile(theFile)
set startDate to (current date) - 20 * minutes
set filepath to alias "HD:Users:User:Documents"
tell application "OmniFocus"
tell front document
set theContext to first flattened context where its name = "context"
set theTask to name of every flattened task where its context = theContext and completed = true and completion date is greater than startDate
set flaggedTask to name of every flattened task where its flagged is true and its completed is not true
end tell
end tell
if number of theTask is greater than 0 then
tell application "Finder"
set filename to name of every file in filepath whose label index is not 6
repeat with theFile in filename
set t to text 1 thru -11 of theFile
if theTask contains t then
set newString to {}
repeat with i in theFile
if (i as string) is " " then
set end of newString to "\\ "
else
set end of newString to (i as string)
end if
end repeat
set n to newString as string
do shell script "/usr/local/bin/tag -s Writing ~/Documents/" & n
end if
if theTask contains t then
set newString to {}
repeat with i in theFile
if (i as string) is " " then
set end of newString to "\\ "
else
set end of newString to (i as string)
end if
end repeat
set n to newString as string
do shell script "/usr/local/bin/tag -s Complete ~/Documents/" & n
end if
end repeat
end tell
end if
if number of flaggedTask is greater than 0 then
tell application "Finder"
set filename to name of every file in filepath whose label index is not 6
repeat with theFile in filename
set t to text 1 thru -11 of theFile
if flaggedTask contains t then
set newString to {}
repeat with i in theFile
if (i as string) is " " then
set end of newString to "\\ "
else
set end of newString to (i as string)
end if
end repeat
set n to newString as string
do shell script "/usr/local/bin/tag -a Flagged ~/Documents/" & n
end if
end repeat
end tell
end if
end hazelProcessFile