Ask Your Question

convert-to command line parameter

asked 2012-05-15 16:14:28 +0200

anonymous user


updated 2013-09-13 20:02:02 +0200

carnendil gravatar image

Hello, I'm trying to convert a Microsoft Word document to text using the convert-to command-line parameter using LibreOffice 3.4.5, OOO340m1 (Build:1505), on OpenSuse 12.1. I tried these two commands.

soffice --convert-to txt filename.doc

Nothing happened.

soffice --headless --convert-to txt filename.doc

Produced a PDF file.

Why do I need --headless? If this is mandatory, the documentation should state this. Can LibreOffice convert Word Perfect documents?

The format for "convert-to" parameter is:

--convert-to output_file_extension[:output_filter_name] [--outdir output_dir]

What are the valid output_file_extension values? What are the valid output_filter_name values?

For the documentation, the soffice --help showed the --convert-to parameter. The help->LibreOffice Help does not show this parameter.

Thank you

edit retag flag offensive close merge delete

6 answers

Sort by » oldest newest most voted

answered 2012-09-25 02:43:18 +0200

jopenid gravatar image

updated 2012-09-25 09:37:03 +0200

Here are a few more pointers for anybody else struggling with this.

This is the general format of convert-to (noting that on windows the parameter is -convert-to not --convert-to):

soffice --headless --convert-to <TargetFileExtension>:<NameOfFilter> file_to_convert.xxx

Use the link above (http://cgit.freedesktop.org/libreoffice/core/tree/filter/source/config/fragments/filters) to look for the filter names in the .xcu files.

For example, I wanted to convert to Excel 95 format so I found the MS_Excel_95.xcu filter and inside it has a name:

<node oor:name="MS Excel 95" oor:op="replace">

I could then try it out:

soffice --headless --convert-to xls:"MS Excel 95" filename.xlsx

(I needed this to get a non-xml version of an excel file)

edit flag offensive delete link more


for me --headless worked only when given after --convert-to.

soffice --convert-to pdf filename.doc  --headless

works while

soffice  --headless --convert-to pdf filename.doc

does not.

the_code ( 2015-01-12 08:08:33 +0200 )edit

answered 2012-05-15 16:30:15 +0200

vmiklos gravatar image

Probably --convert-to should imply --headless, but if you want this, please open a bugreport.

Regarding the filters available, you can poke around at http://cgit.freedesktop.org/libreoffice/core/tree/filter/source/config/fragments/filters (sure, a more user-friendly wiki page would be better), for example if you want to convert to odt, try '--convert-to odt:writer8'.

edit flag offensive delete link more

answered 2012-12-13 21:19:12 +0200

cben gravatar image

updated 2012-12-13 21:49:36 +0200

--headless is not strictly mandatory, but you want it.
Without it, the document is still converted (note "convert /.../filename.doc -> /.../filename.txt using text" message on stdout) but an empty GUI is also started (and the command blocks until you close the GUI).

More importantly, headless conversion silently does nothing if any LO is already open; see http://ask.libreoffice.org/en/question/1686 for a solution.

edit flag offensive delete link more



Thanks, that is a useful caveat about headless conversion only working when no other LOis open, by default. Sure explains why I had trouble before; now I am using the -env trick.

bosyber ( 2013-07-24 20:31:28 +0200 )edit

answered 2013-09-13 14:25:18 +0200

rafik gravatar image

updated 2013-09-13 15:01:32 +0200

On win7, using LO 4.1 I had to do the following (from command line, you probably need to change %f to %%f if running in a cmd script):

set path=%path%;C:\Program Files (x86)\LibreOffice 4\program
for %f in (*.odg) do (
    soffice.exe --headless --convert-to pdf --outdir "C:\tmp" %f


  • it will NOT work if any instance of LO is open!
  • outdir IS required
  • wildcards for input files are NOT supported (hence the for loop)
edit flag offensive delete link more


Thank you very much.

Just a few notes for WIN7 x64 LO build ID 7e4286b58adc75a14f6d83f53a03b6c11fa2903

  • outdir IS NOT reqired (strange?)
  • NOT AT ALL instances of LO are opend, even LO Quick Start

Bear in mind to disable loading LO quick start on operating system startup. Otherwise it will be loaded on first convert and nothing will be coverted after it.

mike_a ( 2013-09-16 14:03:26 +0200 )edit

Couple of noob questions incoming. 1. that is two separate commands? 2. the first command, that looks like it is telling windows where to look for soffice.exe, or is it also looking for the files you want to convert? 3. Do I need to have command prompt open to the directory the files are in for this to work, I am guessing so. 4. If this is all entered in at the same time, do I need to separate the commands in any way?

Kardrik ( 2014-07-23 20:58:27 +0200 )edit

answered 2012-05-16 01:48:00 +0200

w_whalley gravatar image

This syntax worked for LO 3.4.6

soffice --headless --convert-to txt:text file_to_convert.doc

But only if no other instances of LO are open.

edit flag offensive delete link more

answered 2014-11-18 21:36:21 +0200

PrgWiz gravatar image

For windows machines, I have found that on some files the conversion needs a start /wait. Example

start /wait soffice --headless --convert-to txt file_to_convert.doc

It seems the shell collapses before soffice can complete the conversion is some cases.

edit flag offensive delete link more


Thank you for this - on Windows 7 I was getting unhelpful crash dialogs until I added the "start /wait" to the command. As a note the first quoted parameter for 'start' is the window name, so if you try to call the above from a script with a space in the path you may need to do it like: start /wait "" "C:\program files\libreoffice 4\program\soffice"

NickP ( 2014-12-10 01:03:35 +0200 )edit
Login/Signup to Answer


Asked: 2012-05-15 16:14:28 +0200

Seen: 50,618 times

Last updated: Nov 18 '14