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 Today's Posts

 
Script: Filtered export to iThoughtsHD & OPML (& .txt) Thread Tools Search this Thread Display Modes
--
A rough draft of a script which builds on the earlier OF to OPML exporter adding:
  1. Export to the iThoughts formats .itmz and .itm, and to plain tab-indented .txt, as well as to Markdown and FoldingText .todo mode,
  2. some scope for customising (filtering) the set of OmniFocus data which is exported,
  3. some basic options for customising the colors, expansion pattern, etc in iThoughtsHD.

If you create a small and simple iThoughtsHD file (.itmz or unzipped .itm), consisting only of a root node and some coloured top-level branches (anything bigger will slow things down) you can give its pathname in the pstrTemplate property in the header of the script, which should then pick up the main formatting settings of the template, and the set of colours used in its top-level branches.

I attach a sample pastel.itm template, and a bright.itmz template (.itmz files are zipped 'map.itm' files).

Anyone prepared to dip cautiously into SQL (unsupported and at their own risk) should be able to customise the set of data exported by adjusting some properties at the head of the script.

For iThoughtsHD exports, the -c or --collapse switch allows you to specify which levels of the diagram (root=1) are collapsed.

The script is attached, with templates, below.

Note: requires OS X 10.7 and above (Python 2.7)

For reference, its header looks like this:

Code:
-- Copyright (C) 2012 Robin Trew
--
-- Permission is hereby granted, free of charge, 
-- to any person obtaining a copy of this software 
-- and associated documentation files (the "Software"), 
-- to deal in the Software without restriction, 
-- including without limitation the rights to use, copy, 
-- modify, merge, publish, distribute, sublicense, 
-- and/or sell copies of the Software, and to permit persons 
-- to whom the Software is furnished to do so, 
-- subject to the following conditions:

-- *******
-- The above copyright notice and this permission notice 
-- shall be included in ALL copies 
-- or substantial portions of the Software.
-- *******

-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
-- OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

property pTitle : "Export OmniFocus data"
property pVer : "0.021"
property pAuthor : "Robin Trew"
property pSite : "Orginally published on http://forums.omnigroup.com"


property plstFormats : {"OPML", "ITM", "ITMZ", "TXT", "MD", "FT"}

-- OPTION STRINGS, including SQL filter strings
property pstrCollapseLevels : "4"
property pstrTemplate : "" -- Filename of small .itm or .itmz template to look for in same folder as script (for colors etc)
property pstrOutFolder : (path to desktop)

-- SQL filter notes
-- 1. Comma will be translated to AND
-- 2. Neither OR nor bracketing is supported
-- 3. Status strings should not be quoted - ie status = [active|done|inactive|dropped]
-- 4. As usual, the [ = | != ] operators  can not be used with null. Use [is null | is not null]
-- 5. For ALL use the simple filter 1, and for none, use 0
-- No Inbox tasks would be: property psqlInboxFilter : 0

property psqlFolderFilter : "effectiveActive = 1"
property psqlSinglesHoldersFilter : "folderEffectiveActive = 1, status = active, dateCompleted is null"
property psqlProjectFilter : "folderEffectiveActive = 1, status = active, dateCompleted is null"
property psqlTaskFilter : "effectiveContainingProjectInfoActive = 1, dateCompleted is null"
property psqlInboxFilter : "1" -- edit this to "1" for ALL inbox entries, or sth like "dateCompleted is null" to filter

-- SOME ALTERNATIVES
-- Don't show Inbox:
-- property psqlInboxFilter : 0

-- Exclude taskless projects
-- property psqlProjectFilter : "numberOfRemainingTasks > 0, folderEffectiveActive = 1, status = active, dateCompleted is null"

-- Exclude Projects and tasks with future start dates
-- property psqlProjectFilter : "taskBlockedByFutureStartDate=0, folderEffectiveActive = 1, status = active, dateCompleted is null"
-- property psqlTaskFilter : "BlockedByFutureStartDate=0, effectiveContainingProjectInfoActive = 1, dateCompleted is null"

-- OPTION FLAGS
property pblnIncludeOFLinks : false
property pblnIncludeNotes : true
property pblnRecurInfo : false -- prepend any Task Recurrence info to note
Attached Files
File Type: zip OF2MindMap-022.zip (46.9 KB, 3419 views)

Last edited by RobTrew; 2012-10-10 at 12:06 AM.. Reason: Ver 22 – Improves link formatting for MD/FT (flipping any (url)[name] pairs in OF notes to [name](url))
 
Ver 011 above fixes the choice between exporting all filtered data, and only exporting the selected node and all its descendants.

Ver 012 now works with Keyboard Maestro

Ver 014 added info on defaults to all options in help page. (As below)

Running the python file without any arguments at all would export all active data (without links or notes) to a file called current_tasks.itm in the same directory as the script.

Adding the switches -n -l -r for example, would include notes and links back to the original OmniFocus object, and prepend the notes with any recurrence info.

Code:
Usage: ofoc_to_mindmap_021.py [options]

Options:
  -h, --help            show this help message and exit
  -a ROOT, --root=ROOT  Specify a sub-tree by the OmniFocus id of its root
                        node. Defaults to None.
  -x FORMAT, --format=FORMAT
                        Set the export format [itmz | itm | opml | txt | md |
                        ft]. Defaults to tab-indented txt. md is simple
                        Markdown, ft is Markdown with the addition of
                        FoldingText's .todo mode tags for checkboxes and
                        struck-through done items
  -o OUTPUT, --output=OUTPUT
                        Set the export filepath. Defaults to file named
                        current_tasks
  -c COLLAPSE, --collapse=COLLAPSE
                        List the outline levels to collapse. Defaults to 2,4
  -m TEMPLATE, --template=TEMPLATE
                        The pathname of an .itm or .itmz template for
                        iThoughtsHD. Defaults to same directory as script.
  -l, --links           Include OmniFocus task/folder links. Defaults to false
  -n, --notes           Include OmniFocus notes. Defaults to false
  -r, --recurinfo       Add any repetition information to start of notes.
                        Defaults to false
  -f FOLDER_SQL, --folders=FOLDER_SQL
                        SQL clause[s] to limit which FOLDERS are exported.
                        Defaults to effectiveActive=1
  -s SINGLES_SQL, --singlelists=SINGLES_SQL
                        SQL clause[s] to limit which SINGLE ACTION LISTS
                        are exported. Defaults to status=active,
                        folderEffectiveActive=1, dateCompleted is null
  -p PROJECT_SQL, --projects=PROJECT_SQL
                        SQL clause[s] to limit which PROJECTS are exported.
                        Defaults to status=active, folderEffectiveActive=1,
                        dateCompleted is null  Use a comma for AND (OR is not
                        supported) e.g. -p 'childrenCount > 0,
                        blockedByFutureStartDate = 0'
  -t TASK_SQL, --tasks=TASK_SQL
                        SQL clause[s] to limit which TASKS are exported.
                        Defaults to dateCompleted is null,
                        effectiveContainingProjectInfoActive=1
  -i INBOX_SQL, --inbox=INBOX_SQL
                        SQL clause[s] to limit which INBOX TASKS are exported.
                        Defaults to all inbox tasks
--

Last edited by RobTrew; 2012-10-02 at 08:41 AM..
 
For command line, or shell script use, you could make a copy of the python file in the Resources folder of the .scptd package, and use some variant of:

Code:
#!/bin/sh
python $HOME/ofoc_to_mindmap_012.py --format=itm --output=$HOME/Desktop/ActiveTasks -m $HOME/Template.itm -l -n -c '2,4' -f 'effectiveActive = 1' -s 'folderEffectiveActive = 1, status = active, dateCompleted is null' -p 'folderEffectiveActive = 1, status = active, dateCompleted is null' -t 'effectiveContainingProjectInfoActive = 1, dateCompleted is null' -i '1'
Which assumes, for the sake of illustration, that the python script, and a small Template.itm file (containing an example of your preferred formatting and colours for iThoughtsHD) are both in your home directory.

(The help option in the script menu of the Applescript wrapper places a listing of the command line options into the clipboard).

--

Last edited by RobTrew; 2012-09-30 at 07:26 AM..
 
Quote:
Originally Posted by RobTrew View Post
For command line, or shell script use, you could make a copy of the python file in the Resources folder of the .scptd package, and use some variant of:

Code:
#!/bin/sh
python $HOME/ofoc_to_mindmap_012.py --format=itm --output=$HOME/Desktop/ActiveTasks -m $HOME/Template.itm -l -n -c '2,4' -f 'effectiveActive = 1' -s 'folderEffectiveActive = 1, status = active, dateCompleted is null' -p 'folderEffectiveActive = 1, status = active, dateCompleted is null' -t 'effectiveContainingProjectInfoActive = 1, dateCompleted is null' -i '1'
Which assumes, for the sake of illustration, that the python script, and a small Template.itm file (containing an example of your preferred formatting and colours for iThoughtsHD) are both in your home directory.

(The help option in the script menu of the Applescript wrapper places a listing of the command line options into the clipboard).

--
Thanks for the awesome script, Rob.

I am having an issue with running it as shell script. In iThoughtsHD, I create a test map as template, and I save it as Template.itmz. From Hazel on the Mac, I set the shell script to have .itm as output and Template.itmz as template file for colors and shapes.

However, the ActiveTasks.itm file that is generated by the script doesn't open with the color and shape settings of Template.itmz. For instance, I set wireframe and right-angle link styles, and the .itm file opens with S Bend and a different background.

The Template.itmz is in the correct location, as requested by the shell script.

Thanks again!
 
Thanks for the feedback.

The help page should read filename rather than pathname i.e. in the current version any template file needs to be in the same folder as the script. Specifying a full path (rather than just a filename) for the --template option wouldn't work.

(I'll make a note for a future version to allow for templates located in other folders, as specified by a full path given to the --template option.
 
Yes, but I am already specifying a filename for a template file in the same folder of the script.

It's just that when I open the generated .itm file, the styles aren't retained.
 
Oh, and by the way, I have tried both the shell script version and the full AppleScript file. In both cases, the .itm that is created doesn't have the colors and styles of the Template.
 
Quote:
Originally Posted by viticci View Post
Oh, and by the way, I have tried both the shell script version and the full AppleScript file. In both cases, the .itm that is created doesn't have the colors and styles of the Template.
Thanks - my first response was wrong - first of all, it turns out that the script does actually pick up the pathname, as the help page suggests.

For me this kind of thing is working:

-m '/Users/username/Library/Scripts/Applications/Omnifocus/Bright.itmz'

Could I ask you to experiment with trying this with the Bright.itmz and pastel.itm templates in the .zip, to see if they are making a difference on your system ?

(I take it that the script is not reporting failure to find the template ?)

The script does two things with the template:
1. it adopts the plist wrapping of the data
2. it reads the colours just from the top level branches

It may be worth studying the two supplied examples in a text editor (you'll need to unzip the .itmz file and look at the map.itm file which it contains) and comparing them with the template you are using.

--

Last edited by RobTrew; 2012-09-30 at 02:22 PM..
 
Quote:
Originally Posted by RobTrew View Post
Thanks - my first response was wrong - first of all, it turns out that the script does actually pick up the pathname, as the help page suggests.

For me this kind of thing is working:

-m '/Users/username/Library/Scripts/Applications/Omnifocus/Bright.itmz'

Could I ask you to experiment with trying this with the Bright.itmz and pastel.itm templates in the .zip, to see if they are making a difference on your system ?

(I take it that the script is not reporting failure to find the template ?)

The script does two things with the template:
1. it adopts the plist wrapping of the data
2. it reads the colours just from the top level branches

It may be worth studying the two supplied examples in a text editor (you'll need to unzip the .itmz file and look at the map.itm file which it contains) and comparing them with the template you are using.

--
Ok, my bad. I wasn't unzipping the .itmz file so that's why the script wasn't picking up the styles.

It looks like you can't set shapes in the current version. Maybe there's a workaround for this?

For instance, here's the template, and the file based on it.

Template



OF export

 
Quote:
Originally Posted by viticci View Post
Ok, my bad. I wasn't unzipping the .itmz file so that's why the script wasn't picking up the styles.
Shouldn't really have to unzip them - zipped (.itmz) templates seem to be working here.

Quote:
Originally Posted by viticci View Post
It looks like you can't set shapes in the current version. Maybe there's a workaround for this?
Good catch. It seems that the Inherit Shape setting kicks in from the top-level branches rather than from the root node.

Ver 015 now reads the shapes, as well as the colors, from the top level branches of the template, and if Inherit Shape is set, that should cascade down through the diagram.

(Doesn't yet read the root node colour/shape though - I'll get round to that at some point - busy week ahead :-)
 
 




Similar Threads
Thread Thread Starter Forum Replies Last Post
ofexport - export to text, taskpaper, html, opml psidnell OmniFocus Extras 110 2014-04-01 09:36 AM
Batch Export OO to OPML or Text adgirard OmniOutliner 3 for Mac 0 2012-10-04 12:53 PM
Numbered rows in OPML export (perhaps via Applescript?) mjknight OmniOutliner 3 for Mac 0 2011-12-16 08:15 AM
Export to OPML with notes ben_worthington OmniOutliner 3 for Mac 1 2009-01-02 02:06 PM
OPML export doesn't include Topic? corris OmniOutliner 3 for Mac 0 2008-01-29 08:37 AM


All times are GMT -8. The time now is 04:54 PM.


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