How can I convert .odt to .html (or .md) from the commandline?

2

1

I'm looking for free software that can convert OpenDocument to HTML or markdown.

Pandoc can convert HTML to OpenDocument, but not the reverse.

odt2html.py failed to install using both pip and easy_install.

LibreOffice can reportedly do the conversion; however, I couldn't get it to work with the following command:

soffice --convert-to --outdir . htm:HTML my.odt

kqw

Posted 2015-03-04T13:22:36.223

Reputation: 1 781

Answers

3

You're using --convert-to, but you're not specifying the value for it.

The correct syntax is:

soffice --headless --convert-to htm:HTML --outdir . my.odt

Or try to use the following script:

#! /bin/bash

CONFIG=/path/to/tidy_options.conf
# rm -rv "$2"
mkdir -p "$2"

for F in `find $1 -type f -name "*.doc" -or -name "*.odt"`; do
  BASE=`basename $F .doc` ; BASE=`basename $BASE .odt`
  soffice --headless --convert-to htm:HTML --outdir $2 $F
  tidy -q -config $CONFIG -f $2/$BASE.err -i $2/$BASE.htm | sed 's/ class="c[0-9]*"//g' > $2/$BASE.html
done

Usage:

$ convert_doc_to_html.sh SOURCE_DIR TARGET_DIR

See:

kenorb

Posted 2015-03-04T13:22:36.223

Reputation: 16 795

Right! I copied the command from somewhere else and I hadn't noticed the problem with syntax because of the /Applications/LibreOffice.app/Contents/MacOS/ part. Thanks. – kqw – 2015-03-04T14:40:24.233

0

New versions of pandoc, the open source universal document converter, work now:

pandoc -t html -s input.odt -s -o output.html 

Daniel-KM

Posted 2015-03-04T13:22:36.223

Reputation: 1