Last active
January 13, 2017 19:34
-
-
Save valenvb/73860b6b2defd0adbe40 to your computer and use it in GitHub Desktop.
Automatically add notes to an OmniOutliner notes file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {} | |
set noteData to "A note!" --the noteData variable hold the text of the note | |
set fileName to "notes.oo3" --The name of the notes outliner file | |
tell application "OmniOutliner" | |
set oDocs to name of documents of windows | |
set openState to (oDocs contains fileName) | |
open "[path to file]" | |
set doc to document of front window | |
--set date to result of my getDate() | |
set today to my getDate() | |
set ltr to rows of doc where level is 1 | |
set lst to cells of last item of ltr | |
if value of item 2 of lst is not today then | |
set li to value of item 3 of lst | |
--log (li as text) | |
tell its document (name of doc) | |
set nw to make new row with properties {topic:today} | |
end tell | |
set topDoc to nw | |
set cls to cells of nw | |
repeat with i from 1 to number of items in cls | |
set tc to item i of cls | |
--log (name of column of tc as text) | |
if name of column of tc is "Index" then | |
--set visible of column of tc to false | |
set value of tc to (li + 1) as text | |
end if | |
end repeat | |
else | |
set topDoc to last item of ltr | |
end if | |
tell topDoc | |
make new row with properties {topic:noteData} | |
end tell | |
save document (name of doc) | |
if not openState then | |
close document (name of doc) | |
end if | |
end tell | |
end run | |
on getDate() | |
set mth to month of (current date) | |
set dy to day of (current date) | |
set yr to year of (current date) | |
return mth & " " & (dy as text) & ", " & yr as text | |
end getDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment