Batch Convert Multiple File Types

Is there a way to convert multiple file types in a folder with a single command?

I would like to be able to convert any .doc, .docx, .ppt, .pptx, .xls, .xlsx that is added to a folder.

I know how to do this for each individual file type with:

./soffice --headless --convert-to pdf --outdir /FILES2/ /FILES1/*.doc

But would love to be able to handle all files types with one command.

Any help will be greatly appreciated.

That works. There will only be 1 file in this folder and it will be cleared out after conversion.

Thanks for your help.

Please if the answer is right for you, click the √ below the down arrow in the answer.

In basic terms, if you want to convert all your LO readable file formats to PDF you can use file globbing i.e.,

$ soffice --headless --convert-to pdf *.*

Obviously though if you have a.odp, a.ods, a.odt, etc. you are going to overwrite the output PDF from a.odp and a.ods with that for a.odt, so this may not be an ideal solution. For a more complex solution I think you would need to write a script to iterate through your known file types and perform the needed file checking.

This did not work for me using Windows 10 and LibreOffice 6.1.2.1. I created a bat file like this:

for %%x in (*.wps *.doc*) do "\Program Files\LibreOffice\program\soffice" --headless --convert-to odt "%%x"

Thanks a lot !