change filenames but not extension

I have a filename with a bunch of periods that I want to replace with underscores, but I don't want to change the extension.

Ex: I want

file.test1.f-1.fig.eps

to be

file_test1_f-1_fig.eps

Using awk, the following line will replace ALL periods with underscores, but I want to leave the last period for the extension

ls *.eps -print|awk '{f=$0;gsub(/\./,"_");print "mv "f" "$0}'|sh
ls -1 *.eps | while read line; do name=`basename $line .eps`; name=$(echo $name | sed 's/\./_/g'); mv $line $name.eps; done

ls -1 ( numeric one )

Pure shell approach, if you are using bash or ksh:

ls -1 *.eps | while read file ; do
  base=${file%.*}
  suff=${file##*.}
  echo mv $file ${base//./_}.${suff}
done

For explanation see 'man bash' and scroll to "Parameter expansion"