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 Search Today's Posts Mark Forums Read

 
Setting export format with Applescript Thread Tools Search this Thread Display Modes
Hey, so I'm almost finished with my bulk export applescript for OmniOutliner. I've got it working but one last issue I'm having is I cannot seem to figure out how to select the export file type with the exception of .rtf which OO4 seems to like as its default for some reason. Here's the excerpt from the OO applescript dictionary:

Code:
export specifier : the object for the command
   to file : Where to place the exported document.
   [as text] : The name of a writable file type to use when writing the document. Defaults to the appropriate type for the path extension on the export destination.
Now there is only one file type I've been able to get to work, ".rtf", and this is done by just specifying the extension in the file name and not using the "as text" modifier at all. Using any other extension besides ".rtf" causes an error, even though the description above says OO will "default to the appropriate type for the path extension":

Code:
set outputPath to POSIX file ("/Users/mmarotta/Google Drive/Outliner iphone copies/" & theName & ".rtf")
	
	tell application "OmniOutliner"
		tell front document
			export to outputPath
			close
		end tell
	end tell
So since simply changing the extension does not work I went on to try the "[as text]" specifier to manually specify the file format to use. However, no matter what I've tried I always get an error like "OmniOutliner got an error: "HTML" is not a writable file type." no matter what I put after the "as" command:

Code:
set outputPath to POSIX file ("/Users/mmarotta/Google Drive/Outliner iphone copies/" & theName & ".html")
	
	tell application "OmniOutliner"
		tell front document
			export to outputPath as "HTML"
			close
		end tell
	end tell
I've tried everything I could think of after the "as" command, "HTML" "HTML (Dynamic)" ".html" "Microsoft Word Document" "docx" ".docx" I've tried removing the quotes, putting parentheses around it, adding brackets around the 'as' command as shown in the dictionary but none of it seems to work (and I always made sure to have the matching file extension in the output name). Even RTF which I know works without the "as" specifier stops working when I add "as rtf" using any of the above variations.

I must be missing something, how am I supposed to use the "as" command to specify what export file format for OO to use?

Last edited by random1destiny; 2014-03-24 at 08:32 PM..
 
Iíve created an applescript to bulk export Omnioutliner files which I'll post when I'm finished and itís working great but I just canít seem to figure out how to specify the export file format. Hereís the excerpt from the OO applescript dictionary:

Code:
export specifier : the object for the command
   to file : Where to place the exported document.
   [as text] : The name of a writable file type to use when writing the document. Defaults to the appropriate type for the path extension on the export destination.
However, everything Iíve tried gives an error message "However, no matter what I've tried I always get an error like "OmniOutliner got an error: "HTML" is not a writable file type." no matter what I put after the "as" command:

Code:
set outputPath to POSIX file ("/Users/mmarotta/Google Drive/Outliner iphone copies/" & theName & ".html")
	
	tell application "OmniOutliner"
		tell front document
			export to outputPath as "HTML"
			close
		end tell
	end tell
The only thing that works is if I donít use ďasĒ at all and make the extension ď.rtfĒ in the file name section but that only allows me to export rtfís. No other extensions work.

Code:
set outputPath to POSIX file ("/Users/mmarotta/Google Drive/Outliner iphone copies/" & theName & ".rtf")
	
	tell application "OmniOutliner"
		tell front document
			export to outputPath
			close
		end tell
	end tell
I've tried everything I could think of after the "as" command, "HTML" "HTML (Dynamic)" ".html" "Microsoft Word Document" "docx" ".docx" I've tried removing the quotes, putting parentheses around it, adding brackets around the 'as' command as shown in the dictionary but none of it seems to work (and I always made sure to have the matching file extension in the output name). Even RTF which I know works without the "as" specifier stops working when I add "as rtf" using any of the above variations.

I must be missing something, how am I supposed to use the "as" command to specify what export file format for OO to use?
 
The format needs to be specified by the UTI. You can ask the app for "every document type" to get a list of them.

*edit*
actually want to ask for "writable document types" to just get the export formats

Last edited by DerekM; 2014-03-26 at 11:25 AM..
 
Hm, I'm still stuck.

I found this list of UTI's for mac and it showed the UTI as "public.html" for html for example. So I plugged it into the code as:

Code:
export to outputPath as "public.html"
That and other variations did not work either. I seem to be misunderstanding something.

I'm also not sure how I'm supposed to use the "every document type" command, do I need that if I have the list of UTI's above? I tried

Code:
tell application "omnioutliner" 
   display dialog every document type as text
end tell
but I just got an error saying it can't be made into text.

I'm pretty new to applescript so I think I need you to elaborate a little bit more with your answer as I'm obviously missing something. What exactly do I need to type to export exactly the same way as selecting "HTML (Dynamic)" in the OO export options?

And even if I have the correct UTI for html, how do I tell Omnioutliner to differentiate between the HTML and HTML (Dynamic) options you see in OO's export format options?
 
Code:
tell application "OmniOutliner"
    writable document types
end tell
This will return the list of UTIs, assuming you're running it from an AppleScript editor.

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

Though I just noticed this isn't returning a fully correct list, it's missing the HTML options and has some we removed. For HTML you would use:

com.omnigroup.OmniOutliner.HTMLExport.HTMLDynamic
com.omnigroup.OmniOutliner.SimpleHTMLExport.HTML
 
Perfect! Just what I needed, thanks! My script is now working. I'll share it shortly as I think it's something the whole OO community can really benefit from.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -8. The time now is 05:48 PM.


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