Renaming Files using Shell Script

Hi Gurus,
I have some files(all ending with .out as extension).
Ex:
aa1.out
aa2.out
aa3.out

I would like to append each file with the current date to the end of the file so that they should become aa1_20090504.out.
So I am using rename as follows:

for i in path/aa* ; do mv $i `basename dd`_`date +"%Y%m%d"`.out ; done ;
But when I rename, they become as "aa1.out_20090504.out".How can I remove the ".out" extension in the file which comes after the aa1?

Thanks,
Floyd

Hi,
I got the same when I tried

for i in path/aa* ; do mv $i `basename $i .out dd`_`date +"%Y%m%d"`.out ; done ;

Thanks
Floyd

Try This ,it will work only if you want three character filename
i.e. aaa_20090505.out
It will not work for aaaa.out

dd=`date +"%Y%m%d"`
for i in `ls -lrt`
do
x=`echo $i | cut -c 1-3`
y=$x_$dd.out
mv $i $y
done

Try...

for i in aa?.out
do 
      mv $i ${i%.out}$(date "+_%Y%m%d.out")
done

It will work definately ....
for filename of any length
dd=`date +"%Y%m%d"
for i in `ls- lrt`
do
x=`basename $i .out`
mv $i $x_dd.out
done

Try this:

for i in path/aa* 
do 
name=${i%.*}
mv $i $name"_`date +"%Y%m%d"`.out" 
done 

cheers,
Devaraj Takhellambam