Resize of images in a folder with imagemagick

#!/bin/bash
# Hans-Henry Jakobsen
# Script som bl.a resizer bilder og legger de i rett mappe
# NB! ikke bruk originalfil da dette script sletter fila

# Sjekker at mapper eksisterer
if [ ! -d 320 ]
        then
        mkdir 320
fi
if [ ! -d 480 ]
        then
        mkdir 480
fi

for file in  $(ls|grep JPG)
do
        base320=`basename $file .JPG`_Resized_320.png
        base480=`basename $file .JPG`_Resized_480.png

        convert $file -resize 320 $base320
        convert $file -resize 480 $base480

        #320px
        convert $base320 -background black \
        -font Verdana -pointsize 10 -fill black \
        -gravity center -set caption "Copyright \© 2007 Pario.no"  +polaroid \
        320/$base320;

        #480px
        convert $base320 -background black \
        -font Verdana -pointsize 10 -fill black \
        -gravity center -set caption "Copyright \© 2007 Pario.no"  +polaroid \
        480/$base480;

        # Sletter temp filer
        rm $base320
        rm $base480
        # Ikke bruk originalfil da den blir slettet!
        rm ${file}
done

# Ordner rettigheter
chmod g+rw 320/*
chmod g+rw 480/*
chgrp knausen 320 -R
chgrp knausen 480 -R