View Single Post
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