Skip to content

Instantly share code, notes, and snippets.

@ChewingPencils
Created October 21, 2012 22:39
Show Gist options
  • Save ChewingPencils/3928796 to your computer and use it in GitHub Desktop.
Save ChewingPencils/3928796 to your computer and use it in GitHub Desktop.
Creates an NVAlT note from an OmniFocus Task
--
-- Created by: Sean Korzdorfer
-- Created on: 06/08/12 17:05:27
-- This script incudes code from an example posted by Rob Trew
-- String Library can be obtained at:
-- http://applescript.bratis-lover.net/library/string/
-- Any line which contains a path needs to be edited for the users environment
-- NB: this could easily be edited to append.
set scriptLibraryPath to ":Volumes:MacintoshHD:USERNAME:Dropbox:bin:" & "stringlib.scpt"
set scriptLibrary to load script scriptLibraryPath as alias
tell front window of application "OmniFocus"
set scriptLibraryPath to ":Volumes:MacintoshHD:USERNAME:Dropbox:bin:" & "stringlib.scpt"
set scriptLibrary to load script scriptLibraryPath as alias
-- try
set oTrees to selected trees of content
set lngTrees to count of oTrees
if lngTrees < 1 then
set oTrees to selected trees of sidebar
end if
if lngTrees < 1 then
return
end if
if (lngTrees > 0) then
repeat with iTree from 1 to lngTrees
set SelectedItemInMainView to selected trees of content
set theSelection to value of (item iTree of oTrees)
if class of theSelection is folder then
set theNote to ""
else if class of theSelection is project then
set theNote to ""
else if class of theSelection is inbox task then
set theNote to note of theSelection
else
set theNote to note of theSelection
end if
set theTag to ""
set tag_list to {"create", "read", "check", "research", "watch", "mine"}
set theName to name of theSelection
repeat with i from 1 to the count of tag_list
if item i of tag_list is equal to word 1 of theName then
set theTag to "@" & lowerString(word 1 of theName) of scriptLibrary
end if
end repeat
if theTag is "@check" then set theTag to "@check-out"
set theName to lowerString(theName) of scriptLibrary
set theDate to creation date of theSelection as string
set thePath to "/Volumes/MacintoshHD/USERNAME/Dropbox/notes/nvalt/" & theName
-- set theNote to theDate & return & return & theName & return & theNote
set theNote to theNote & return & return & "----" & return & theTag & return & theDate
set var to "echo " & the quoted form of theNote & "> /Volumes/MacintoshHD/USERNAME/Dropbox/notes/nvalt/" & the quoted form of theName & ".txt"
do shell script var
do shell script "touch /Volumes/MacintoshHD/USERNAME/Dropbox/notes/nvalt/" & the quoted form of theName & ".txt"
set oTask to value of (item iTree of oTrees)
end repeat
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment