Batch Conversion of PNGs to PDFs
Some quick shell scripts (sh and csh) to convert all the PNG files in a directory to PDF files. The command for conversion was found on Mac OS X Hints. The difference between the two is how variables are set and the loop syntax.
#!/bin/sh
#
# Convert png files to PDFs. Command found on OS X Hints
# http://www.macosxhints.com/article.php?story=20040402201110611
#
# /usr/bin/sips -s format pdf file.png -o file.pdf
# output directory (should create)
odir=./PDFs
for file in *.png
do
echo "Converting $file"
# check basename
#echo `basename -a -s .png $file`
# convert file using basename
base=`basename -a -s .png $file`
/usr/bin/sips -s format pdf $file -o $odir/$base.pdf
done
#!/bin/csh
#
# Convert png files to PDFs. Command found on OS X Hints
# http://www.macosxhints.com/article.php?story=20040402201110611
#
# /usr/bin/sips -s format pdf file.png -o file.pdf
# output directory (should create)
set odir = ./PDFs
foreach file (`ls *.png`)
echo "Converting $file"
# check basename
#echo `basename -a -s .png $file`
# convert file using basename
set base = `basename -a -s .png $file`
/usr/bin/sips -s format pdf $file -o $odir/$base.pdf
end