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 4 for Mac
FAQ Members List Calendar Today's Posts

 
OO Bulk Export Script and How To Sync And View Your OO Collection On Your iPhone/PC/devices Thread Tools Search this Thread Display Modes
I just finished up writing a bulk export script for Omnioutliner as well as put together an automated solution to make these available for view on your iPhone or any other device that currently cannot read Omnioutliner documents. I know many have long awaited being able to at least view OO documents on their iPhones/PC/etc and the following will provide an automated solution. Even when Omni comes out with an iPhone app this system will still be useful for those looking to access up to date data on PC's, android, or any computer without OO installed.

The instructions below look pretty long but the setup is really quite simple, it just looks long because I provide multiple implementation options for each main step to make this work for the most people. People may have different syncing solutions, ways they like to run their scripts, export format choices, etc and I wanted to make sure I addressed as much as I could, so don't be intimidated.

***
Part 1 The Script

Disclaimer: Always back up your data just in case.

Attached is the applescript. There are extensive directions and annotations in it to help with configuring it for your system, but the essential steps are

1) Change the two existing paths to match the directory with your outlines and the directory you want to export to (they can be the same). Depending on your sync solution you may need to export to a certain directory like your Dropbox folder (more on this later). Note: The script will search all subfolders for outlines.

2) Optional: You can change the export format by changing Both the extension of the output file as well as replacing the export type identifier after the "as" command. (thoughts on file type selection later)

There are some additional features I've added to this script.

A) Instead of exporting every file every time this script actually checks and compares the modification dates of the OO3 and exported file to see if there have actually been any new changes to the file. This is to keep the footprint light as this script is meant to be run periodically around the clock to always keep your exports up to date.

B) This design is assuming that you will not be editing your exported files (ie using them read only). There are instructions to disable this if you plan on editing your exported files but I don't recommend this as it will be very hard to keep track. Best to jot down notes somewhere else and add them to the OO files when you are back at your computer.

C) Keeps any currently open outlines open after exporting so you are not interfered with. However, if there other documents being exported they may flash quickly when the script is run. I have not figured out how to open documents via applescript without them coming to the front intially.

D) You can add names of files you don't want exported

***
Part 2 Running the script periodically

There are several ways to run the script.

The free way is to just use iCal to schedule the script to run at a set interval. I believe you can also make the script into an app and add extra code to have it run periodically. Of course, you can also just run it manually every time you want to update all your exports.

The way I do it is I use a program from the Mac App Store called Scenario. This app lets you set a script to run whenever the computer is idle or screensaver comes on. This is great because the script/exporting will only happen when you are not working guaranteeing you won't be interfered with (even though the script as written will rarely bother you). There are ways to accomplish this for free with just code so it depends if you want to do the extra effort or just buy the program.

***
Part 3 Sync/make the exported files available to your devices

The final step is to sync all your exports.

A quick note about export file format choice first: I recommend using only either HTML (Dynamic) or Microsoft Word (.docx). This is because these are the only two formats which export the entire outline contents no matter what. The others will not actually export any rows that are in a collapsed row, so unless you can remember to keep all your outlines fully expanded at all times I would stick withe HTML Dynamic or Word. HTML Dynamic is really the best of all because it both preserves indentation and you can actually collapse rows dynamically. The only downside is it's a bit trickier to sync because I found they don't work as well with Dropbox and Google Drive for some reason.

The most obvious way is just to put the exported files in the folder of an automatic syncing solution like Dropbox or Google Drive and access them through their iPhone apps or publicly share the folder. You will want to use Word as your export format if you go this route, and this is perfectly fine for shorter outlines. If any of you can get HTML Dynamic working in these or other sync services let me know (this, and viewing other file types in general, would be a great feature for OmniPresence to implement, *hint* *hint*)

For the ultimate experience you'll want to export to HTML Dynamic and make them available to your other devices. What I do is put the files up on a directory on my web hosting. I set up an FTP watch folder with my FTP client that automatically syncs any new/changed files to my host (I use YummyFTP because it's rock solid reliable but I think free clients like Cyberduck have this, too). I can password protect directories on my host so this works really well for me. The FTP watch folder is actually located in my Google Drive so I still do have offline access to the raw html in case I really need it but can't view it through my browser.

***
So that should give you everything you need to make all your omni notes/data available and up to date anywhere and on any platform.

I think in this day and age of fully synced Google Docs, Evernote, Office Online, etc, it is crucially important for a software/format like OmniOutliner at make its data portable, at least viewable/read only. I'm hoping Omni can bake all this into their existing products so an external solution isn't even necessary, they really have most of the pieces in hand.

This is my first applescript so let me know if you see anything that can be done better. One thing I couldn't figure out is how to preserve the folder structure in the export folder to keep the same organization your outline were in.
Attached Files
File Type: zip Omnioutliner Bulk Export v1.0.scpt.zip (8.2 KB, 25650 views)

Last edited by random1destiny; 2014-03-26 at 09:06 PM..
 
Code:
--Exports all oo3 files in folder and exports to desired folder. v1
--Instructions:
--Edit paths to your outline and export folder (put export folder in your Dropbox/Google Drive or similar account to access these on iphone or any computer without omnioutliner)
--Edit both output file extension as well as export file type to use a different file type. See below for list of file types. 
--Schedule to run periodically to keep iphone copies up to date. You can use ical or I found a program called "Scenario" that runs scripts when computer is idle so you are not interfered with while working. 
--This script assumes you will not be editing the exported files by comparing modification dates of the outline and exported file. If you do plan on editing these files you need to eliminate the line: "if modification date of (info for eachFile) is greater than the modification date of (info for outputPath) then"
--Notes:
--Keeps any currently open outlines open after exporting so you are not interfered with. However, if there other documents being exported they may flash quickly when the script is run. I have not figured out how to open documents via applescript without them coming to the front intially. 


--Add any file names you do not want to be exported
set ignoreFiles to ""

--Gather all oo3 files in folder
tell application "Finder"
	--USER: Change this path to your outlines folder
	set fl to (files of entire contents of folder POSIX file "/Users/user/my outlines folder/" whose name extension is "oo3") as alias list
end tell

--Make note of any files that are currently open so they are not closed unnecessarily later
tell application "OmniOutliner"
	set openOutlines to name of every document
end tell



repeat with eachFile in fl
	--Set output file path and name
	set theName to name of (info for eachFile)
	--USER: Change this path to your destination folder
	set outputPath to POSIX file ("/Users/user/Google Drive/Outliner iphone copies/" & theName & ".html")
	
	--Logic to export only files that need to be exported
	--ignore any files specified in ignore list above
	--check if output file already exists
	--if it does only export if file has been modified more recently than exported file (note: disable this IF statement if you plan on editing your exported files, this is assuming you'll only be read-only accessing the exported files on your iphone/etc)
	--if exported files doesn't exist then export and create it for the first time
	if ignoreFiles does not contain name of (info for eachFile) then
		tell application "Finder" to if exists outputPath then
			if modification date of (info for eachFile) is greater than the modification date of (info for outputPath) then
				export_file(eachFile, outputPath, openOutlines) of me
			end if
		else
			export_file(eachFile, outputPath, openOutlines) of me
		end if
	end if
	
end repeat

--Subroutine to open, export, and close file
on export_file(eachFile, outputPath, openOutlines)
	tell application "OmniOutliner"
		open eachFile
		tell front document
			--USER: change the text in the quotes to one of the file types listed at the bottom to change export type (current selection is HTML Dynamic)
			export to outputPath as "com.omnigroup.OmniOutliner.HTMLExport.HTMLDynamic"
			--only close file if it wasn't already open before so your open documents are not interfered with
			if openOutlines does not contain name of (info for eachFile) then
				close
			end if
		end tell
	end tell
end export_file


--Output file types:
--org.opml.opml
--com.apple.rtfd
--com.omnigroup.omnioutliner.oo3
--com.microsoft.word.openxml.document
--com.omnigroup.omnioutliner.oo3template
--com.omnigroup.omnioutliner.oo3template-package
--com.omnigroup.omnioutliner.oo3-package
--com.apple.iwork.keynote.key
--com.omnigroup.omnioutliner.plain-text.fixed-width
--public.rtf
--public.plain-text
--com.omnigroup.OmniOutliner.WordExport.MSWordHTML
--com.omnigroup.OmniOutliner.HTMLExport.HTMLDynamic
--com.omnigroup.OmniOutliner.SimpleHTMLExport.HTML
 
Quick start instructions

Since my instructions came out so long here's the barebones instructions to get started right away assuming you have something like a free Dropbox account:

1) Open the script up in Applescript Editor.app. Change the two existing paths to match the directory with your outlines and the directory you want to export to (any folder in your dropbox account will work).

2) Change the file extension of the output file to ".docx", and change the 'export as' format to "com.microsoft.word.openxml.document" (because this format works best with dropbox/google drive)

3) Press the "Run" button in Applescript editor and it should export to the dropbox or whatever sync folder you selected and now be available on your devices.

4) If that works then create a repeating event in iCal and set it to run this script to your desired interval.

That's the bare bones basic setup. Read the long directions above for all the little tweaks and enhancements you can do to customize the syncing format/service/interval/etc.

Last edited by random1destiny; 2014-03-27 at 02:24 PM..
 
Thanks for sharing this. Works great,
 
Great to hear!
 
Mods, I can't edit my original message. Is there a way to put a note at the beginning to "view the Quick Start Instructions below" so people aren't turned away by the full instructions?
 
 





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


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