4

Tip #544   Change extension of files in the current directory

This tip is inspired by #27 ( http://www.shell-fu.org/lister.php?id=27 ) which I think is misleading, here's a much more reliable and efficient version:

rename_ext() {
   local filename
   for filename in *."$1"; do
     mv "$filename" "${filename%.*}"."$2"
   done
}


use it like:


rename_ext php html


to rename all .php files to .html in the current directory.