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

 
Exporting the whole OF database to OPML Thread Tools Search this Thread Display Modes
hi Rob, I've tried that one also...

of2omnioutlinerpro does not bring the folder names over (but it fixes the problem with the missing note)

of2opml does bring folder names, but has the missing note bug.

I could paypal you a token $20 for a fix, if that is of any motivation.

(I really don't understand why all the omni things don't import export to eachother already!)

thanks for your great and generous work with the scripts!
 
Will you send it to me, instead? Rob's asleep :-)

I've attached a modified version of OF2OPML that handles project notes in the same fashion as action notes.
Attached Files
File Type: zip OF2OPML-03.applescript.zip (2.0 KB, 236 views)
 
hi!

got the revised script from Palmer. works!

going to send you $20, just need your email for paypal, so PM it to me I guess...

also going to send $20 to RobTrew for original applescript work.

thanks!
now that I have a correct opml I can look at other organizer options like Curio.

still seems choices are limited, but unless I can solve my hanging problems with omnifocus I have to switch.

again thanks to both of you. the payment is just a token for your generous work.
 
Quote:
Originally Posted by Shotster View Post
Hope it works for you.
Thanks! I didn't get a notification on your reply, so sorry for my late reply.

I'm mainly interested in your replacement method, because German has a couple of weird characters as well.

When I got a working version I plan to share my results.

Again, thanks.
Andreas
 
Quote:
Originally Posted by whpalmer4 View Post
Will you send it to me, instead? Rob's asleep :-)

I've attached a modified version of OF2OPML that handles project notes in the same fashion as action notes.
Thank you !

Meanwhile, I've updated the OF2OO script, which should now export folders.

(As it's based on GUI selections, to export folders with tasks as well as the projects, you need to choose 'group by folders' in the content panel, and select the folders required - their descendant trees will be picked up automatically).

--

Last edited by RobTrew; 2012-01-31 at 08:04 AM..
 
Needed to change some things, Rob and the others might want to consider for their version of this script.

I got a list of entities from this page. A short regex (s/(.)\t(.*)\t.*/set retVal to stringReplace("$1", "$2", retVal)/) to get working AS code.

I found a bug in the replacement code which can be fixed by adding considering case.

Here's the entire script.

Thanks to everyone involved!

Code:
-- Indicative draft Ver 0.001

-- Saves anything selected in Omnifocus (Project or Context View) As an OPML
-- Including the following fields: DONE, NOTE, CONTEXT, PROJECT, START, DUE, COMPLETED, DURATION, FLAGGED}
-- Note that the whole sub-tree is copied, so only 'parent' elements need to be selected.

property pPROJECT : "project"
property pTASK : "task"
property pINBX_TASK : "inbox task"
property pITEM : "item"

property pOPMLHeadToExpand : "
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<opml version=\"1.0\">
	<head>
	<title>Selected in OF</title>
	<expansionState>"
property pOPMLHeadFromExpand : "</expansionState>
	</head>
	<body>
 "

property pOPMLTail : "
	</body>
</opml>"

property pNodeStart : "<outline "
property pLeafClose : "/>"
property pParentClose : "</outline>"

on run
	set strOPML to MakeOPML(SelectedInOF())
	if strOPML ≠ "" then
		set oFile to choose file name with prompt "Save as OPML" default name "Untitled.opml" default location (path to desktop) as alias
		WriteText2Path(strOPML, POSIX path of oFile)
	end if
end run

-- READ SELECTED OmniFocus CONTENT TREE(S) TO NESTED APPLESCRIPT LISTS - Ver.04

on SelectedInOF()
	tell application "OmniFocus"
		tell front window
			set blnContext to ((selected view mode identifier) is not equal to pPROJECT)
			
			repeat with oPanel in {content, sidebar}
				set lstNodes to value of (selected trees of oPanel where class of its value ≠ item)
				set lngNodes to count of lstNodes
				if lngNodes > 0 then exit repeat
			end repeat
			set blnAll to (lngNodes < 1)
			if blnAll then set lstNodes to value of (trees of content where class of its value ≠ item)
		end tell
		
		repeat with i from 1 to length of lstNodes
			tell item i of lstNodes
				if (its class) is not folder then
					if (number of tasks) > 0 then
						--set item i of lstNodes to {name, completed, my ListSubNodes(its tasks, blnContext, blnAll), note, "", "", start date, due date, completion date, estimated minutes, flagged}
						set item i of lstNodes to {name, completed, my ListSubNodes(its tasks, blnContext, blnAll), note, "", "", start date, due date, completion date, estimated minutes, flagged}
						
						
						
					else
						set item i of lstNodes to {name, completed, {}, note, "", "", start date, due date, completion date, estimated minutes, flagged}
					end if
				else
					if (number of projects) > 0 then
						set item i of lstNodes to {name, false, my ListSubNodes(its projects, blnContext, blnAll), note, "", "", missing value, missing value, missing value, missing value, false}
					else
						set item i of lstNodes to {name, false, {}, note, "", "", missing value, missing value, missing value, missing value, false}
					end if
				end if
			end tell
		end repeat
		
		return {lstNodes, blnContext}
	end tell
end SelectedInOF

on ListSubNodes(lstNodes, blnAll)
	using terms from application "OmniFocus"
		repeat with i from 1 to length of lstNodes
			tell item i of lstNodes
				
				set oProj to its containing project
				if oProj is not missing value then
					set strProject to name of oProj
				else
					set strProject to ""
				end if
				
				set oContext to its context
				if oContext is not missing value then
					set strContext to name of oContext
				else
					set strContext to ""
				end if
				
				if (number of tasks) > 0 then
					set item i of lstNodes to {name, completed, my ListSubNodes(its tasks, blnAll), note, strProject, strContext, start date, due date, completion date, estimated minutes, flagged}
				else
					set item i of lstNodes to {name, completed, {}, note, strProject, strContext, start date, due date, completion date, estimated minutes, flagged}
				end if
			end tell
		end repeat
		return lstNodes
	end using terms from
end ListSubNodes


-- BUILD OPML

on MakeOPML({lstTasks, blnContext})
	if (length of lstTasks > 0) then
		
		set {lngIndex, strExpand, strOutline} to my Tasks2OPML(-1, lstTasks, tab)
		set strOPML to pOPMLHeadToExpand & strExpand & pOPMLHeadFromExpand & strOutline & pOPMLTail
		return strOPML
	end if
end MakeOPML

on Tasks2OPML(lngIndex, lstTasks, strIndent)
	set {strExpand, strOut} to {"", ""}
	repeat with oTask in lstTasks
		set {strName, blnDone, lstChiln, strNote, strProject, strContext, dteStart, dteDue, dteDone, lngMins, blnFlagged} to oTask
		
		if strNote ≠ "" then
			set strOut to strOut & pNodeStart & Attr("text", strName) & Attr("_note", strNote)
		else
			set strOut to strOut & pNodeStart & Attr("text", strName)
		end if
		
		if blnDone then if (dteDone is not missing value) then
			set strOut to strOut & Attr("_status", "checked") & Attr("Completed", short date string of dteDone & space & time string of dteDone)
		end if
		
		if strProject ≠ "" then set strOut to strOut & Attr("Project", strProject)
		if strContext ≠ "" then set strOut to strOut & Attr("Context", strContext)
		
		tell dteStart to if it is not missing value then set strOut to strOut & my Attr("Start", short date string & space & time string)
		tell dteDue to if it is not missing value then set strOut to strOut & my Attr("Due", short date string & space & time string)
		
		if lngMins > 0 then set strOut to strOut & Attr("Duration", ((lngMins / 60) as string) & "h")
		if blnFlagged then set strOut to strOut & Attr("Flagged", "2")
		
		set lngIndex to lngIndex + 1
		if (length of lstChiln > 0) then
			set strExpand to strExpand & "," & (lngIndex) as string
			set {lngIndex, strSubExpand, strSubOutln} to Tasks2OPML(lngIndex, lstChiln, strIndent & tab)
			if strSubExpand ≠ "" then set strExpand to strExpand & "," & strSubExpand
			set strOut to strOut & ">" & return & 
				strIndent & strSubOutln & return & 
				strIndent & pParentClose
		else
			set strOut to strOut & pLeafClose & return
		end if
	end repeat
	if strExpand begins with "," and length of strExpand > 1 then set strExpand to text 2 thru -1 of strExpand
	return {lngIndex, strExpand, strOut}
end Tasks2OPML

on Attr(strName, strValue)
	--strName & "=\"" & strValue & "\" "
	strName & "=\"" & attributeValue(strValue) & "\" "
end Attr

on WriteText2Path(strText, strPosixPath)
	set f to (POSIX file strPosixPath)
	open for access f with write permission
	write strText as class utf8 to f
	close access f
end WriteText2Path

on attributeValue(str)
	set retVal to stringReplace("&", "&amp;", str)
	set retVal to stringReplace("\"", "&quot;", retVal)
	set retVal to stringReplace("<", "&lt;", retVal)
	set retVal to stringReplace(">", "&gt;", retVal)
	set retVal to stringReplace("
", "
", retVal)
	
	-- additions for all sorts of characters and umlauts
	set retVal to stringReplace("", "&Agrave;", retVal)
	set retVal to stringReplace("", "&Aacute;", retVal)
	set retVal to stringReplace("", "&Acirc;", retVal)
	set retVal to stringReplace("", "&Atilde;", retVal)
	set retVal to stringReplace("", "&Auml;", retVal)
	set retVal to stringReplace("", "&Aring;", retVal)
	set retVal to stringReplace("", "&AElig;", retVal)
	set retVal to stringReplace("", "&Ccedil;", retVal)
	set retVal to stringReplace("", "&Egrave;", retVal)
	set retVal to stringReplace("", "&Eacute;", retVal)
	set retVal to stringReplace("", "&Ecirc;", retVal)
	set retVal to stringReplace("", "&Euml;", retVal)
	set retVal to stringReplace("", "&Igrave;", retVal)
	set retVal to stringReplace("", "&Iacute;", retVal)
	set retVal to stringReplace("", "&Icirc;", retVal)
	set retVal to stringReplace("", "&Iuml;", retVal)
	set retVal to stringReplace("", "&ETH;", retVal)
	set retVal to stringReplace("", "&Ntilde;", retVal)
	set retVal to stringReplace("", "&Ograve;", retVal)
	set retVal to stringReplace("", "&Oacute;", retVal)
	set retVal to stringReplace("", "&Ocirc;", retVal)
	set retVal to stringReplace("", "&Otilde;", retVal)
	set retVal to stringReplace("", "&Ouml;", retVal)
	set retVal to stringReplace("", "&Oslash;", retVal)
	set retVal to stringReplace("", "&Ugrave;", retVal)
	set retVal to stringReplace("", "&Uacute;", retVal)
	set retVal to stringReplace("", "&Ucirc;", retVal)
	set retVal to stringReplace("", "&Uuml;", retVal)
	set retVal to stringReplace("", "&Yacute;", retVal)
	set retVal to stringReplace("", "&THORN;", retVal)
	set retVal to stringReplace("", "&agrave;", retVal)
	set retVal to stringReplace("", "&aacute;", retVal)
	set retVal to stringReplace("", "&acirc;", retVal)
	set retVal to stringReplace("", "&atilde;", retVal)
	set retVal to stringReplace("", "&auml;", retVal)
	set retVal to stringReplace("", "&aring;", retVal)
	set retVal to stringReplace("", "&aelig;", retVal)
	set retVal to stringReplace("", "&ccedil;", retVal)
	set retVal to stringReplace("", "&egrave;", retVal)
	set retVal to stringReplace("", "&eacute;", retVal)
	set retVal to stringReplace("", "&ecirc;", retVal)
	set retVal to stringReplace("", "&euml;", retVal)
	set retVal to stringReplace("", "&igrave;", retVal)
	set retVal to stringReplace("", "&iacute;", retVal)
	set retVal to stringReplace("", "&icirc;", retVal)
	set retVal to stringReplace("", "&iuml;", retVal)
	set retVal to stringReplace("", "&eth;", retVal)
	set retVal to stringReplace("", "&ntilde;", retVal)
	set retVal to stringReplace("", "&ograve;", retVal)
	set retVal to stringReplace("", "&oacute;", retVal)
	set retVal to stringReplace("", "&ocirc;", retVal)
	set retVal to stringReplace("", "&otilde;", retVal)
	set retVal to stringReplace("", "&ouml;", retVal)
	set retVal to stringReplace("", "&oslash;", retVal)
	set retVal to stringReplace("", "&ugrave;", retVal)
	set retVal to stringReplace("", "&uacute;", retVal)
	set retVal to stringReplace("", "&ucirc;", retVal)
	set retVal to stringReplace("", "&uuml;", retVal)
	set retVal to stringReplace("", "&yacute;", retVal)
	set retVal to stringReplace("", "&thorn;", retVal)
	set retVal to stringReplace("", "&yuml;", retVal)
	set retVal to stringReplace("", "&szlig;", retVal)
	
	return retVal
end attributeValue

on stringReplace(find, replace, subject)
	considering case
		
		set prevTIDs to text item delimiters of AppleScript
		set text item delimiters of AppleScript to find
		set subject to text items of subject
		
		set text item delimiters of AppleScript to replace
		set subject to "" & subject
		set text item delimiters of AppleScript to prevTIDs
		
	end considering
	
	return subject
end stringReplace
 
For the longer table of higher-code substitutes you could also use numeric encoding.

Something like this, perhaps:
Code:
on Encode(str)
	set lstChars to characters of str
	repeat with i from 1 to length of lstChars
		set lngCode to id of item i of lstChars
		if lngCode > 127 then set item i of lstChars to ("&#" & lngCode as string) & ";"
	end repeat
	lstChars as Unicode text
end Encode
 
I have updated the original code to version 2.0 to allow for encoding of special characters and diacritics.

(I've used a Python library function for the syntactically significant characters, and numerically encoded anything else above 127)
 
Updated the original code in post 4 removing pre-header space, and adding post-attribute space, for better compatibility with apps like Tree and iThoughts.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting to an OPML app then PDF idea2go OmniOutliner for iPad 18 2013-09-27 06:38 AM
Exporting OF Library to OPML for iThoughts HD Mschechter OmniFocus 1 for Mac 0 2012-07-29 06:57 AM
OPML exporting and formatted text macula OmniOutliner 3 for Mac 6 2010-06-09 06:53 AM
Exporting to Keynote and OPML xiamenese OmniOutliner 3 for Mac 2 2009-10-30 08:10 PM
Exporting to OPML using AppleScript atobe OmniOutliner 3 for Mac 5 2008-05-30 02:11 AM


All times are GMT -8. The time now is 01:16 AM.


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