typing Command line document conversion with LibreOffice

Easily convert between document formats using the powerful LibreOffice command line.

I have many documents created with Microsoft Office, written for assignments during graduate school courses, years ago. How can I easily convert those dozens of documents to a different format without using an online application? This is an excellent example of the power of open source.

Converting from DOCX to ODT

Five years ago, I took a course at a local university where all of the documents were provided in DOCX format. Is there a way to convert those documents to an ODT format? There is, and it is quite simple by using LibreOffice, the open source office suite. LibreOffice is available on Linux, Mac, and Windows.

$ libreoffice --headless --convert-to odt *.docx

Converting from DOCX to HTML

What if I decided I wanted to convert those DOCX items to HTML so they could easily be shared on my classroom website? What if I had wanted to convert all those documents to HTML?

$ libreoffice --headless --convert-to html *.docx

Exporting to PDF

I can use the same tool to convert those DOCX files into PDF files with a single iteration of the same command.

$ libreoffice --headless --convert-to pdf *.docx

There's more to explore

Using LibreOffice from the command line inside the directory where the files you want to convert are is easy, and the conversion is accomplished in a matter of seconds, depending on your processor and memory. You can find many more uses of LibreOffice from the command line by entering the following command on your own command line if you have LibreOffice installed, as most Linux distributions do.

$ libreoffice --help

This is an excellent example of the power of open source software.


This article is adapted from Bulk Document Conversion Made Easy with LibreOffice by Don Watkins, and is republished with the author's permission.