This repository was archived by the owner on Jul 18, 2018. It is now read-only.
forked from hhje22/ExportThings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExportThings.applescript
More file actions
executable file
·85 lines (69 loc) · 2.59 KB
/
ExportThings.applescript
File metadata and controls
executable file
·85 lines (69 loc) · 2.59 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
# ExportThings - for exporting Things database to the Desktop as Things Backup.txt
# Dexter Ang - @thepoch on Twitter
# Copyright (c) 2012, Dexter Ang
#
# Somewhat based on "Export Things to text file (ver 1)" by John Wittig
# and from reading the Things AppleScript Guide (rev 13).
#
# Tested with Things 2.0.1 and OS X Mountain Lion
#
# TODO:
# - Get Repeating ToDos (currently no way via AppleScript).
# - Make tags tab delimited by heirarchy.
# - Export Areas. Maybe.
# - For each exported ToDo, also include their tags and areas. Maybe.
#
set theFilePath to (path to desktop as Unicode text) & "Things Backup.txt"
set theFile to (open for access file theFilePath with write permission)
set eof of theFile to 0
tell application "Things" to activate
tell application "Things"
log completed now
empty trash
set theList to {"Inbox", "Today", "Next", "Scheduled", "Someday", "Projects"}
write "----------" & linefeed to theFile
repeat with theListItem in theList
write "| " & theListItem & ":" & linefeed & linefeed to theFile
set toDos to to dos of list theListItem
repeat with toDo in toDos
set tdName to the name of toDo
set tdDueDate to the due date of toDo
set tdNotes to the notes of toDo
write "- " & tdName & linefeed to theFile
if tdDueDate is not missing value then
write ">> Due: " & date string of tdDueDate & linefeed to theFile
end if
if tdNotes is not "" then
# Append a "tab" to each line of tdNotes.
repeat with noteParagraph in paragraphs of tdNotes
write tab & noteParagraph & linefeed to theFile
end repeat
end if
# Special case for Projects, we get the tasks for each project.
if (theListItem as string = "Projects") then
set prToDos to to dos of project tdName
repeat with prToDo in prToDos
set prtdName to the name of prToDo
set prtdDueDate to the due date of prToDo
set prtdNotes to the notes of prToDo
write tab & "- " & prtdName & linefeed to theFile
if prtdDueDate is not missing value then
write tab & ">> Due: " & date string of prtdDueDate & linefeed to theFile
end if
if prtdNotes is not "" then
# Append a "tab" to each line of tdNotes.
repeat with prnoteParagraph in paragraphs of prtdNotes
write tab & tab & prnoteParagraph & linefeed to theFile
end repeat
end if
end repeat
end if
end repeat
write linefeed & "----------" & linefeed to theFile
end repeat
write "| Tags:" & linefeed & linefeed to theFile
repeat with aTag in tags
write "- " & name of aTag & linefeed to theFile
end repeat
close access theFile
end tell