Using the --convert-to command-line function to convert formats under Windows 10
We will consider the .docx to .odt conversion, but the syntax and steps are the same for other formats supported by LibreOffice.
On MS-Windows 10 we can use a command like soffice.exe --convert-to odt my_document.docx in order to convert my_document.docx from the MS docx format to the open document format (odt). The --convert-to function allows us to specify a set of documents by using the general wildcard syntax for files. For exemple it is legal to use *.docx when you have a bunch of docx files to convert from the current directory.
But when used in the Windows Command shell, it does not work at all. It seems that all the conversions are started simultaneously, and since two instances of LibreOffice (soffice.exe) cannot run at the same time when launched from the command line, the process will never end. At best, you will end with one or two files converted, but in any case you will have to kill manually a bunch of LibreOffice processes hung in the system (twice as much as the number of files found, at first sight).
To overcome this, a simple way is to use the new Windows Subsystem for Linux Environment provided by MS for its version 10 of Windows. You may have to install it, what is quite straightforward if you follow the documentation here https://docs.microsoft.com/en-us/windows/wsl/install-win10.
Once done, you will have access to quite a nice bash shell running on top of the Windows base system, and the --convert-to function will work properly, in a synchronous mode.
- Identify the path to soffice.exe.
- cd to the directory containing the files to convert, after having created a destination directory.
- Give this command : <path to soffice.exe> --convert-to odt --outdir <my_output_directory> *.docx
"/mnt/c/Program Files/LibreOffice 5/program/soffice.exe" --convert-to odt --outdir ./Converted_To_odt *.docx will convert the docx files from the current directory to their equivalent into the ./Converted_To_odt subdirectory.
The WSL mounts a complete file system on its own. So, the syntax to specify a file location in the directory tree is different from the Windows one. The first difference is the root point : Under Windows it uses to be C:\, the equivalent in the bash shell is /mnt/c/. Than, the token separator under Windows is \, in the bash it is the / Unix one. For the rest, the rules are the same, the bash shell supports the same character set as the Windows command shell as well as long filenames and filenames with spaces, provided that they are delimited by double-quotes (").
How to create the command ?
The easiest way is to examine the shortcut you use every time you start LibreOffice. Right-click on it, than "Properties", than copy the "Target" field content. In the example given, it will be "C:\Program Files\LibreOffice 5\program\soffice.exe". Than adjust the syntax to the bash requirements as described before, to get this : "/mnt/c/Program Files/LibreOffice 5/program/soffice.exe" Beware, Unix is case-sensitive, Windows is not.
For the rest, you are done.
Using the bash shell on Windows is an easy way to convert a bunch of files from a format to another using LibreOffice builtin command-line function. It works quietly.
Or the Simplest way, interactive
It is even simpler to use the builtin LibreOffice Document converter Assistant, as described here : https://help.libreoffice.org/latest/en-US/text/shared/autopi/01130000.html.
You can start it by clicking in the Menu Files - Assistants - Document Converter...
Some user has reported that he had to cut its files lot in bunches of 200 pieces, because the process crashed sometimes.