Batch conversion and setting font size from Linux terminal (CLI). Possible?

I need to batch convert and change a few parameters (specifically, font size and zoom percentage) in more than a hundred of DOC files to be converted to DOCX. I can see a few similar threads online using the CLI parameters --convert-to and --infilter, but they’re mostly focused on manipulating the font of the converted documents, not the font size, for example.

So how can I change the font size and zoom percentage of the converted DOC documents from the terminal (command line)? I’m using LibreOffice 7.6.2 on Pop!_OS 22.04 (Ubuntu-backed Linux OS).

Thank you!

Get a Windows PC and edit those 100 docs with MS Word and a trivial VBA macro.

Please share a link. --convert-to and infilter can’t change anything in DOC, which has the font information inside. Only for plain text (filter name "Text (encoded)"), infilter allows you to pass font.

You need a macro to do what you want - open files, edit them, save as another format.

Of course, you need to realize that opening a foreign file format (DOC) introduces conversion errors (because of imperfect filter, and differences in document models / concepts). Saving to another external file format (DOCX) adds more conversion errors. So you should be ready that (some of) your hundred resulting files could be different from your expectations.

Thank you for detailed answer! I’ll pay heed to your tips.

There is something similar here, using a bash script that can come in handy for what I’m asking for. I can try it before someone comes with a better solution. Thanks!

Cross posted on Reddit

If you cross post, as a courtesy please let us know that you have done so, otherwise it leads to several discussions and a waste of time because several identical answers may be posted by different users.

I wrote an example a while back, Set page margins using OOO Development Tools (OooDev).

Maybe someting like this can be adopted to open your DOC files and make the changes and then save them a DOCX.

What Fonts need to be change, Is it updating styles or changing directly on paragraphs etc?

See Also: Write Modify Character FontOnly Class of OooDev

If you cross post, as a courtesy please let us know that you have done so

@robleyd Thank you for a friendly reminder! I will.

Thank you! I’d like to be able to simply change the font and its size in the whole document. That’s it! The thing is our company requires a specific font for all the documents, while the current ones are written in Times New Roman 12. But the text written in point 12 with the font that we use looks smaller, so I need to set the font size to 13 or so to make it look almost like the original text spanning the same number of pages.

Sounds simple enough but here is the old saying “Easier said then done”.
I a not sure how to the sanme number of pages can be enforeced when changing the font size.

The Font and styles can be applided in different ways. Therefore the approach may be diffenrent on how to change the fonts. If using LIbreOffice API via a macro or a scritp this will matter.

My first thought is convert a test doc file to docx or LibreOffice odt. Both are acutually just zip files. I perfer odt beause I find the unzipped xml easier to read.
Afte after test file is created the make a copy of it.
in the copy open it with LibreOffice Writer, make the changes you want to see and then save it and Exit LibreOffice.

Next Unzip both the original test file and the copy into there respective folders.
Now start comparing the xml files in both original and copy. Find the differences and note them.

If the difference are only few and are consistant then I would consider converting all you files, then usiing a script such as python, Loop throught the odt or docx files and unzip them, do a find and replace on the appropriate xml files, then zip the files back up into a new document.

Example XML

<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
 <style:text-properties fo:font-size="11pt" officeooo:rsid="0016603c" officeooo:paragraph-rsid="0016603c" style:font-size-asian="11pt" style:font-size-complex="11pt" />
<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
 <style:text-properties fo:font-size="12pt" officeooo:rsid="0016603c" officeooo:paragraph-rsid="0016603c" style:font-size-asian="12pt" style:font-size-complex="12pt" />

There may be simpler ways to do this, this is off the top of my head.

Can you provide a sample document in doc and a converted document in odt for us.
Make the changes you want to see in the odt file. Please alos note what the changes are here as a post. I can take a look then and better understand the issue and may have a better solution.