How to batch convert .doc or .docx to .pdf

Solution 1:

lowriter can be used as a command line tool (lowriter is a part of LibreOffice)

lowriter --convert-to pdf *.doc
convert /home/bodhi/Documents/testdoc2.doc -> /home/bodhi/Documents/testdoc2.pdf using writer_pdf_Export
convert /home/bodhi/Documents/testdoc.doc -> /home/bodhi/Documents/testdoc.pdf using writer_pdf_Export

evince testdoc.pdf

I do not have windows, so testdoc download from here

www.mltweb.com/prof/testdoc.doc

Solution 2:

I use unoconv, which converts all formats supported by LibreOffice.

Solution 3:

I use the following script:

for f in *.doc
do
lowriter --headless --convert-to pdf "$f"
done

--headless will prevent Libreoffice from opening 100s of files and eventually crashing if you try this with directories containing a lot of .doc files