Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mass rename in linux? 1

Status
Not open for further replies.

cleansedbb

Technical User
Feb 11, 2002
95
US
this is probably a stuipd ? but is there a way to
do a mass rename?

I basically want to have all *.html changed to *.ltr

Any info would be helpful

 
Probably this is not the most sophisticated solution, but if you use the Korn shell it works like that:

create a list of all files ending with .html:
$ LIST=`ls` (back quotes!)

then just a for loop where the list is parsed in:

$ for file in $LIST
> do
> temp_name=${file%.*}
> mv $file $temp_name
> mv $temp_name $temp_name.ltr
> done

Hope that helps!

mrjazz [pipe]
 
for file in *.html
do
newname=`echo $file | sed -e 's/.html/.ltr/'`
mv $file $newname
done

 
thank you all, they all work. gregsimpsons worked best since it was quick an simple.
*tips hat*

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top