-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcache-notes.applescript
More file actions
44 lines (34 loc) · 1.56 KB
/
cache-notes.applescript
File metadata and controls
44 lines (34 loc) · 1.56 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
property bundleid : "com.surrealroad.alfred-note"
property cacheFile : "cache.plist"
on run
set myPath to path to me
tell application "Finder" to set workflowFolder to (folder of myPath) as string
set lib to load script file (workflowFolder & "alfred_library.scpt")
set wf to load script file (workflowFolder & "q_workflow.scpt")
set wf to wf's new_workflow_with_bundle(bundleid)
set cachePath to wf's _data & cacheFile
--create plist if it doesn't already exist
if not wf's q_file_exists(cachePath) then
-- OS 10.10 workaround
do shell script "defaults write " & quoted form of cachePath & " cacheInProgress 0"
end if
wf's set_value("cacheInProgress", (lib's unixtime(current date)), cacheFile)
tell application id "com.apple.notes"
set existingNotes to {}
set noteList to every note
repeat with note_item in noteList
set noteRecord to {uid:note_item's id}
set noteRecord to noteRecord & {title:note_item's name}
if note_item's body is not missing value then set noteRecord to noteRecord & {notebody:note_item's body}
set noteRecord to noteRecord & {creationdate:note_item's creation date}
set noteRecord to noteRecord & {parentfolder:(note_item's container's name)}
set end of existingNotes to noteRecord
end repeat
set closeNotes to wf's get_value("closeNotes", cacheFile)
if closeNotes is not missing value and closeNotes then quit
end tell
wf's set_value("timestamp", (current date), cacheFile)
wf's set_value("existingReminders", existingNotes, cacheFile)
wf's set_value("cacheInProgress", 0, cacheFile)
return
end run