The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Applescript for Appending Notes to Selected Rows Thread Tools Search this Thread Display Modes
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:

http://muninn.net/blog/2010/03/omnio...cted-rows.html

You may also find a download link from that posting.
 
A variant on this useful theme -

This version:
  1. Appends to (rather than replacing) the existing note
  2. Leaves the notes of the selected rows expanded, so that the result is visible

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
--

Last edited by RobTrew; 2010-05-06 at 03:27 AM..
 
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
 
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
--

Last edited by RobTrew; 2011-03-06 at 08:42 PM..
 
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
--

Last edited by RobTrew; 2011-03-07 at 09:47 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggling color of selected rows between 2 or more colors RobTrew OmniOutliner 3 for Mac 1 2011-03-01 01:20 PM
Is there a way to have check boxes only on selected rows? MichaelG OmniOutliner 3 for Mac 5 2008-05-30 12:05 PM
Reverse order of selected rows random1destiny OmniOutliner 3 for Mac 1 2007-10-15 03:30 PM
Fully expand collapse only selected rows random1destiny OmniOutliner 3 for Mac 2 2007-09-24 08:33 AM
batch change of selected columns/rows talazem OmniOutliner 3 for Mac 0 2006-07-21 09:25 AM


All times are GMT -8. The time now is 07:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.