Applescript for Appending Notes to Selected Rows
I created an open source applescript for appending a note (either from the clipboard or via dialog prompt, one script for each) to a group of selected rows.
I explained why this might be useful for PhD students and scholars engaged in organizing source notes for a large writing project in a posting here: [url]http://muninn.net/blog/2010/03/omnioutliner-applescript-to-append-a-note-to-selected-rows.html[/url] You may also find a download link from that posting. |
A variant on this useful theme -
This version:[LIST=1][*][B]Appends[/B] to (rather than replacing) the existing note[*]Leaves the notes of the selected rows [B]expanded[/B], so that the result is visible[/LIST] [CODE]property pDlgTitle : "APPEND CLIPTEXT TO NOTES (SELECTED ROWS)" try set strClip to Unicode text of (the clipboard as record) if length of strClip > 0 then tell application "OmniOutliner Professional" tell front document set refRows to a reference to selected rows repeat with oRow in refRows set strNote to note of oRow if length of strNote > 0 then set note of oRow to strNote & return & strClip else set note of oRow to strClip end if end repeat set note expanded of refRows to true end tell end tell else display dialog "Clipboard empty ..." with title pDlgTitle end if on error display dialog "No text in Clipboard ..." with title pDlgTitle end try [/CODE] [COLOR="White"]--[/COLOR] |
I've modified Konrad Lawson's script to include a clickable link to a file, rather than a text note.
This script: a) Shows a standard "choose file" dialog box to allow the user to pick a file from their system b) Replaces the notes of the selected lines in OmniOutliner with a clickable link to that file. The goal of this was to use OO to take notes on a PDF (for academic research, for example), and semi-automatically add a link to the original PDF. This way, the link (and reference info) will stay with the outline text as it is copied or moved to a word processor. As an added bonus, if your PDFs are named in a meaningful way (such as Author-Year-Title.pdf), the link also serves as a nice human-readable reference. Zotero, my favorite open-source reference manager, can do this file renaming for you (no affiliation, just a fan), or you can do it manually before running the script of course. To Do List: I like the additions made by RobTrew (append the new info to the note instead replacing the existing info, and auto-expand the modified items at the end), but I wasn't able to get them to work with my script. Perhaps someone with better AppleScript skills can do that. Currently, the script allows filenames and paths containing: spaces = & + / @ $ but not \ ; | { }[ ] ^ < # I'll work on escaping those characters soon. Apologies for not investigating how to do GNU public licensing, but this is based on Konrad Lawrence's script above and input from Tony T1 on Apple's appleScript forum. [CODE]on ReplaceText(theString, fString, rString) set current_Delimiters to text item delimiters of AppleScript set AppleScript's text item delimiters to fString set sList to every text item of theString set AppleScript's text item delimiters to rString set newString to sList as string set AppleScript's text item delimiters to current_Delimiters return newString end ReplaceText tell application "OmniOutliner" set MyDoc to front document set theReply to (choose file) set myPath to "file://localhost" & POSIX path of theReply set myString to ReplaceText(myPath as string, " ", "%20") of me set note of selected rows of MyDoc to myString end tell[/CODE] |
Haven't tested this, but for url encoding you might experiment with simply using the shell. Something along these lines, for example:
[CODE]on encode(strPath) do shell script "python -c 'import sys, urllib as ul; print ul.quote(sys.argv[1])' " & ¬ quoted form of strPath end encode[/CODE] [COLOR="White"]--[/COLOR] |
To append new files, rather than delete incumbent files, and to leave the the notes expanded, you could experiment with a draft like this:
[CODE]tell application "OmniOutliner Professional" if (count of documents) < 1 then return tell front document set refRows to a reference to (selected rows) if (count of refRows) < 1 then return set theReply to (choose file) set strPath to "file://localhost" & my encode(POSIX path of theReply) set oTmpRow to make new row at end of rows with properties {note:strPath & return} set refParas to a reference to paragraphs of note of oTmpRow repeat with oRow in refRows duplicate refParas to after paragraphs of note of oRow end repeat set note expanded of refRows to true delete oTmpRow end tell activate end tell on encode(strPath) do shell script "python -c 'import sys, urllib as ul; print ul.quote(sys.argv[1])' " & ¬ quoted form of strPath end encode[/CODE] [COLOR="White"]--[/COLOR] |
All times are GMT -8. The time now is 11:45 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.