How to (batch) convert Microsoft Office Files from commandline?

Hello,

I’m using LibreOffice 3.4 on Fedora 16. I want to batch convert lots of .xls/x, .doc/x, and .ppt/x files to plain text.

  1. When I issue the following command to just try to convert a single file, the command fails silently with an exit code of 1.

    $ soffice.bin --headless --convert-to txt foo.xls

    $ echo $?

    1

    $

  2. I’d also like to know how to efficiently convert a whole bunch of these files without starting and stopping LibreOffice everytime. It appears that the --accept argument may be the way, but there seems to be no example of this anywhere. Would greatly appreciate if you could share one.

Many thanks in advance,
/HS

In the terminal, use the following command to batch convert Microsoft Office documents into Libreoffice ones.

soffice --headless --convert-to odf *.doc --outdir YourOutputDirectoryHere/

Libreoffice is awesomeness, FYI.

Cool! Thanks for the command line! One could run “*.doc*” to get both DOC and DOCX in one pass, if that wildcard didn’t get some unwanted hits. Also, it looks like that bug mentioned by @drone27of1 is still a problem: fdo#37531 (and when I first ran the string from cli, I got nothing!).

Bug 44496 - convert-to pdf:writer_pdf_Export (headless) fails when LibreOffice already open

Close down all LO instances and it works (tested)

Thanks. Can’t upvote your answer due to insufficient points.

Wow, I had racked my brains for many hours with this issue, by trying powershell scripts and some downloaded Windows crapware.

Finally Libre Office and Linux showed the way via this forum.

BTW, with the later version of LO under Ubuntu, the command line changes to this:

libreoffice --headless --convert-to pdf .doc

Worked a treat.

Sheer genius, I thank you all so very much

Can’t speak to the batch capabilities off hand, but as your looking for a command line tool, the first thing that comes to mind is AntiWord. It supports Word files up to MS Office 2003. Unfortunately, if it’s not in your repos the RPM links on that page are all out of date (latest version is 0.37 from 2005). I had to build it from source myself recently. I’ve always found it to work quite well, but I only use it in combination with less for older *.doc files.

Anyway, I hope I’ve given you a step forward and not fed you a red herring.

Thanks, but I need a converter for not just Word but for Excel and PPT as well. Can’t upvote your answer due to insufficient points.