Friday, December 17, 2004

Batch convert word docs to pdf (unix version)

This is a Bash shell script to convert word docs into pdfs. It uses a command line tool called Antiword to read the Word document and output it to postscript.

Then it uses ghostscript to convert it to pdf. It also checks the folder every 60 seconds to see if a new file has been added and processes it.

It's not perfect but mostly works well. Obviously you need to install Antiword and Ghostscript and make sure they are in you Path variable. 100% Microsoft and Adobe free:

#! /bin/bash
while ((1));
do
for docfile in *.doc;
do
antiword -i O -p letter $docfile | pstopdf -i -o ${docfile%.+([!/])}.pdf;
rm $docfile
done
sleep 60;
done

Listen to this article Listen to this article

0 Comments:

Post a Comment

<< Home