Batch conversion of xlsx to xls via CLI

file conversionms officeopen sourcepython

I'm trying to convert a bunch of xlsx files to xls (because some other software<cough>matlab<cough> can process xls but not xlsx on the mac).

I've tried unoconv but it has issues (which apparently stem from pyuno's shared object not being 64-bit-compatible — even trying to override this with

$ VERSIONER_PYTHON_PREFER_32_BIT=yes ./unoconv

still dies, this time with Fatal Python error: Interpreter not initialized (version mismatch?) which I'm surmising has to do with a mismatch between the python used with OpenOffice and the one shipped with MacOS X).

I'm using the Microsoft-provided "Open XML Converter" in the meantime, but I'd really like to figure out a way to do it with FOSS tools and via the shell. Any ideas?

Oh, I'm running on Snow Leopard if that makes any difference.

Best Answer

I've not tried this with .xls(x) files per say, but I have used LibreOffice to batch convert .doc(x) files to .pdf using the convert-to option. OpenOffice has the same options, afaik.

Check the help option for your app. In my case it was:

/Applications/LibreOffice.app/Contents/MacOS/soffice -help

In particular, for my switch to .pdf files, I did something like this:

/Applications/LibreOffice.app/Contents/MacOS/soffice -headless -convert-to pdf:writer_pdf_Export *.doc

The -headless flag just prevents the whole GUI from loading. There is likely a similar output file extension and filter (the pdf:writer_pdf_Export) for your .xls(x) case.