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 > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Copy as (RTF-formatted) labelled link Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
In the OmniFocus main menu,
Edit > Copy As Link
is invaluable, placing a link like omnifocus:///task/ft9gpCMAZSF in the clipboard.

Useful as it is to be able to jump straight to an OF folder, project, task or context from another application, these raw links are dauntingly illegible, and give little clue to the identity of their target.

This script works just like Edit > Copy As Link, but the RTF-formatted links which it places in the clipboard hide the raw url behind the human-readable name of the target task, project, context or folder. They can be pasted into any rich text editor or field, such as OF notes, OO3 rows or notes, or in TextEdit, DevonThink, etc.

If several items are selected in the OF content panel, a series of links on different lines will be copied to the clipboard. If nothing is selected in the content panel, links for any sidebar selections will be copied.

(The same thing can be achieved by dragging out of OF into a rich text editor, but my patience for mice and the time they waste is short :-)

In fact, I now notice that Cmd C does this anyway, so the above is really just an idle curiosity :-)

on run
end run

-- (Such links can be pasted into rich text editors like OO3, TextEdit etc)
-- (If nothing is selected in the content panel, links are made for any selections in the sidebar)
on CopyAsRTFLabelledLink()
	tell application id "com.omnigroup.omnifocus"
		tell front document window of front document
			repeat with oPanel in {content, sidebar}
				set refSeln to (a reference to selected trees of oPanel)
				if (count of refSeln) > 0 then exit repeat
			end repeat
			if (count of refSeln) < 1 then return
			set lstObjects to value of refSeln
		end tell
		set strHTML to ""
		repeat with oSeln in lstObjects
			tell oSeln
				set strClass to class as string
				if strClass = "project" then set strClass to "task"
				if strClass is in {"folder", "task", "context"} then set strHTML to strHTML & ¬
					"<font face=\"Helvetica\"><a href=\"" & "omnifocus:///" & strClass & "/" & ¬
					id & "\">" & name & "</a></font><br>" & linefeed
			end tell
		end repeat
	end tell
	do shell script "echo " & quoted form of strHTML & "  | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
end CopyAsRTFLabelledLink

Last edited by RobTrew; 2011-02-12 at 08:47 AM.. Reason: slight edit to code (class <> item --> class is in folder|task|context)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
link to pdf instead of copy? nicoledb OmniOutliner 3 for Mac 3 2013-02-27 12:53 PM
Copy Magnet link URL bug Drayon OmniWeb Bug Reports 1 2013-01-11 12:42 PM
Blending features of Quick Entry and Copy As Link? korm OmniFocus Extras 0 2012-09-27 06:32 AM
Can I export/copy a formatted file to Pages? nm2 OmniOutliner for iPad 5 2011-05-12 01:33 PM
Copy as Link to project not working after a Sync mlevin777 OmniFocus 1 for Mac 4 2011-03-09 03:23 PM

All times are GMT -8. The time now is 01:37 PM.

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