#!/bin/bash
for jpg in "$@" ; do                         
    png="${jpg%.jpg}.png"                    
    echo converting "$jpg" ...               
    if convert "$jpg" jpg.to.png ; then      
        mv jpg.to.png "$png"                 
    else                                     
        echo 'error: failed output saved in "jpg.to.png".' 1>&2
        exit 1
    fi                                       
done                                         
echo all conversions successful