#!/bin/bash
for eps in "$@" ; do                         # use $eps in place of each filename given, in turn
    png="${eps%.eps}.png"                    # find the PNG version of the filename by replacing .eps with .png
    echo converting "$eps" ...               # output status info to the user running the script
    if convert "$eps" eps.to.png ; then      # use the convert program (common in Linux) to create the PNG in a temp file
        mv eps.to.png "$png"                 # if it worked, rename the temporary PNG image to the correct name
    else                                     # ...otherwise complain and exit from the script
        echo 'error: failed output saved in "eps.to.png".' 1>&2
        exit 1
    fi                                       # the end of the "if" test construct
done                                         # the end of the "for" loop
echo all conversions successful              # tell the user the good news
exit 0
