[ask]rename file

dear all,

i have case with this:
i have file 20110601.txt so i want to auto rename this file like this 20110601_20110602.txt

actual this rename will create if 20110601 came in date 20110602(date from system unix)

so this will be using

#!/bin/bash

folder='/home'
desti='/home/desti'
now= $( date "+%Y%m%d")
if $folder/yyyymmdd=$now
then
 cat >$desti/$nows.txt
else
 cat >$desti/yyyymmdd_yyyymmdd(date_now).txt
fi

whats should i do for this??

and how i can rename if file like bdg.2011062915666.485.txt tobe 20110629.txt

yesterday_date=`date -d "1 day ago" +%Y%m%d`
today_date=`date +%Y%m%d`
for i in *$yesterday_date.txt
do
 name=`basename $i .txt`
 cp $i /home/desti/$name_$today_date.txt
done

@itkamaraj thx for replaying

solve with this because that file like
bca.20110201231.321.txt
asd.20110302311.313.txt

for i in `ls *.txt`
do
 temp=`echo $i | awk -F '.' '{sub(".",$2);print substr($2,0,9)}'`
 now=$(date '+%Y%m%d')
 
 cat "$i" >> "$temp"_"$now".TXT

done

ok guys my case this one solve i can doing like this

#!/bin/bash
FILE='/home/tux/tesitng/file/'
STAGING='/home/tux/tesitng/staging/'

for i in `find $STAGING -name "*.txt"`
do
 temp=`echo $i | awk -F '.' '{sub(".",$2);print substr($2,0,9)}'`
 now=$(date '+%Y%m%d')
 if [ "$temp" = "$now" ]
    then
     cat "$i" >> $FILE/"$temp".TXT
    else
     cat "$i" >> $FILE/"$temp"_"$now".TXT
 fi
done

thx for visiting :smiley: