Renaming file extensions with bash script

A couple of weeks ago I had to rename the file extension of several view scripts from html (from my own mvc framework) to phtml (zend framework). I found, as always, bash to be my friend.

for i in *
do
  ( file $i | grep html ) && mv $i $(echo $i | sed s/html$/phtml/)
done
by Claus Witt

April 30, 2009  Tags: , , , ,   Posted in: Development

One Response

  1. Jesper Rasmussen - April 30, 2009

    The force of shellscripting is strong in this one..

    Learn advanced scripting you must, zsh use you will ;)