Ask Your Question

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

asked 2012-02-24 07:10:58 +0200

Harry gravatar image

updated 2020-08-20 02:21:36 +0200

Alex Kemp gravatar image


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 $?



  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

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-11-02 19:22:40.970689

3 Answers

Sort by » oldest newest most voted

answered 2012-02-24 08:26:52 +0200

drone27of1 gravatar image

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

Close down all LO instances and it works (tested)

edit flag offensive delete link more


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

Harry gravatar imageHarry ( 2012-02-25 04:58:25 +0200 )edit

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

Frankr gravatar imageFrankr ( 2015-07-09 13:05:04 +0200 )edit

answered 2013-06-19 17:01:16 +0200

Roadapathy gravatar image

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.

edit flag offensive delete link more


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!).

David gravatar imageDavid ( 2013-06-19 19:10:27 +0200 )edit

answered 2012-02-24 08:01:20 +0200

ArtificePrime gravatar image

updated 2012-02-24 08:02:46 +0200

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.

edit flag offensive delete link more


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.

Harry gravatar imageHarry ( 2012-02-25 05:01:03 +0200 )edit

Question Tools


Asked: 2012-02-24 07:10:58 +0200

Seen: 8,060 times

Last updated: Jun 19 '13