Created
May 26, 2012 23:59
-
-
Save davidnunez/2795676 to your computer and use it in GitHub Desktop.
Script that copies selected items in omnifocus to a format suitable for pasting in my nvalt system
This file contains hidden or 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
property newContextName : "txfr" --context the item will change to if changeContext = true | |
tell application "Finder" | |
set the clipboard to "" | |
end tell | |
tell application "OmniFocus" | |
tell document 1 | |
set newContextID to id of item 1 of (complete newContextName as context) --new | |
set newContext to first context whose id is newContextID --new | |
tell (first document window whose index is 1) | |
set SelectedItemInMainView to selected trees of content | |
repeat with i from 1 to (count of SelectedItemInMainView) | |
set theSelectedTask to value of item i of SelectedItemInMainView | |
set nameSelectedTask to name of theSelectedTask | |
set noteSelectedTask to note of theSelectedTask | |
set createdDateSelectedTask to creation date of theSelectedTask | |
try | |
set contextSelectedTask to name of the context of theSelectedTask | |
on error | |
set contextSelectedTask to "" | |
end try | |
set formattedDate to do shell script "date -j -f \"%A, %B %e, %Y %l:%M:%S %p\" \"" & createdDateSelectedTask & "\" \"+%Y-%m-%d-%H%M\"" | |
--display dialog "- " & createdDateSelectedTask & "-N " & nameSelectedTask | |
tell application "Finder" | |
set currentClipboard to get the clipboard | |
if noteSelectedTask is not equal to "" then set the clipboard to ((the clipboard) & return & "---------" & return) | |
set the clipboard to ((the clipboard) & "- " & formattedDate & "-N " & nameSelectedTask & return) | |
if noteSelectedTask is not equal to "" then set the clipboard to ((the clipboard) & noteSelectedTask & return & return & "---------" & return) | |
end tell | |
--set theFilePath to (path to the current user folder as string) & "Dropbox:Brain:Inbox.txt" | |
--set theFileReference to open for access theFilePath with write permission | |
--write (the clipboard as «class utf8») to theFileReference | |
--close access theFileReference | |
--display dialog "1" & name of newContext | |
--set the context of item i of SelectedItemInMainView to context "txfr" | |
set context of theSelectedTask to newContext --new | |
set completed of theSelectedTask to true | |
end repeat | |
end tell | |
end tell | |
end tell | |
-- notification of success | |
set the_file to "/System/Library/Sounds/Glass.aiff" | |
set the_file to POSIX file the_file | |
set file_path to quoted form of (POSIX path of (the_file as alias)) | |
do shell script ("afplay " & file_path & " > /dev/null 2>&1 &") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment