renaming and number padding using directory as guide, help

I need to take a series of image files, all numbered consecuativly, that were recently dumped in a directory and rename them to pieces of the directories path. Assume all directories are structured as this one so that I may use this script to easly sort and rename files.

pt.1
path : /home/shots/pic/seasons/winter/snowy

I need the script to recognize pieces of the path as variables to the images new name.

pt.2
path : /home/$NAME/pic/seasons/$SEASON/

I then need the file which is named xyxy.1.tif to be named in the following convention

pt.3
name : $NAME_$SEASON.0001.tif

the number needs to be repadded with 4 digits

I have been hacking at it for the past two days and have comeup with a rather large mess and have finally broken down and called out for help. I had it half working in Perl my knowlege of that is even more limited then the BASH shell. Thanks

I'm more of a Korn shell man, myself. Here is a solution for that:

#!/bin/ksh

    typeset -Z4        IMG=0

    DIR=/home/shots/pic/seasons/winter/snowy/

    NAME=$(expr "$DIR" : "/home/\([^/]*\)/pic")
    SEASON=$(expr "$DIR" : ".*seasons/\([^/]*\)/")

    for FILE in $(find $DIR -type f -name "*.tif")
    do
        echo "mv $FILE ${NAME}_${SEASON}.${IMG}.tif"

        (( IMG += 1 ))
    done

how are you using that expr command?

lol, nevermind got it.