Rename all files at a time

i have some bar files in a directory

appp1.APP.RTP.DEV1
appp2.APP.RTP.DEV1
appp3.APP.RTP.DEV1

need to be renamed as

appp1.APP.mmk.DEV1
appp2.APP.mmk.DEV1
appp3.APP.mmk.DEV1

i need to rename all files at a time.

Can you search the forum

$ ls -1
appp1.APP.RTP.DEV1  
appp2.APP.RTP.DEV1  
appp3.APP.RTP.DEV1
$ rename 's/RTP/mmk/' appp*.APP.RTP.DEV1
$ ls -1
appp1.APP.mmk.DEV1  
appp2.APP.mmk.DEV1  
appp3.APP.mmk.DEV1
$ uname -a
Linux lark 2.6.32-21-generic-pae #32-Ubuntu SMP Fri Apr 16 09:39:35 UTC 2010 i686 i686 i686 GNU/Linux

Hello hanson44,

It's not working :frowning:

Below is my output:


[root@dhcppc116 files]# ls
appp1.APP.RTP.DEV1  appp2.APP.RTP.DEV1  appp3.APP.RTP.DEV1
[root@dhcppc116 files]# rename 's/RTP/mmk' *.DEV1
[root@dhcppc116 files]# ls
appp1.APP.RTP.DEV1  appp2.APP.RTP.DEV1  appp3.APP.RTP.DEV1
[root@dhcppc116 files]# 

[root@dhcppc116 ~]# uname -a
Linux dhcppc116 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386 GNU/Linux 

Maybe the following glitch?

rename 's/RTP/mmk' *.DEV1

vs

rename 's/RTP/mmk/' *.DEV1

Or maybe you just made an error when you copied and pasted?

I will try that , anyway i solved it by following code :

for i in *.DEV1
do
fname1=`basename $i .RTP.DEV1`
mv "$i" "$fname1.mmk.DEV1"
done

Thanks!!

Yes, the short shell script is a fine way.