Converting Word Processor Files at the Command Line with LibreOffice Writer

Recently, I came across some documents that I'd written at a former Day JobTM. A company that uses That Other Word Processor. You know the one I mean ...

I wanted to convert those files to both ODT and PDF. Opening them individually in LibreOffice Writer to do the deed would have been a chore. Plus, I'm lazy. So I needed to find a different solution.

Then I remembered that you can run LibreOffice Writer from the command line. Really! And, in doing so, you can convert files in bulk. To do that, crack open a terminal window. Then type:

lowriter --convert-to [file-format] *.[file-extension]

To convert the files I wrote using that other word processor to ODT, I typed:

lowriter --convert-to odt *.docx

In a few seconds, I had a bunch of ODT files. I did the same thing to create a bunch of PDF files, just substituting odt in the command with pdf.

You can convert between files in any format that LibreOffice Writer supports. You can also convert individual files. Just type the name of the file at the end of the command.

But what about spreadsheets and slide decks? You can also use the —convert-to option with the commands localc (LibreOffice Calc) and loimpress (LibreOffice Impress) to convert a file or to do a batch conversion.

Scott Nesbitt

#linux #cli #opensource #libreoffice