Liam Delahunty: Home Tips Design Web Words Links Contact

 

Panda Internet Security 2007 - $15 Discount Coupon
CoffeeCup Software
Download Free Web Design Software Here

Sponsors:

Think I deserve a present? See my Amazon Wish List


Linux - Renaming Files

Renaming multiple files in a single directory

I tried the following "script" in a shell...


for i in `ls *.php3`; 
do 
mv $i `echo $i|tr 'php3' 'php'`;
done

with the intention of renaming all the files in a folder from .php3 to .php... WRONG Instead, I now have *.phpp

(BTW I repaired my error with rename phpp php *.phpp)

This would have worked:

for file in *.php3
do
mv $file `basename $file .php3`.php
done

...or...

for i in *.php3; do mv "$i" `echo "$i" | sed 's/\.php3$/.php/'`; done

Please also see how-to rename a single file or a directory

Share this!  



Linux Rename Directory | Linux Rename Files | Linux Search And Replace Multiple Files


 

  Tips | Home | Search | Contact

Link here: