I have wanted a way to rename all files with one extension to another extension for some time now ... and finally figured out a way to do so without writing a script. The first thing most people think of is something like mv *.txt *.rtf, but that will never work because the targets will not expand the wildcard in that way. Next you might try xargs or find with -exec, but the extension becomes a problem because you can only append to it. The solution: the following command will rename all the files in the folder with the .txt extension to .rtf:
This can be applied to other commands like find instead, so be careful:
ls *.txt | sed 's/\(.*\)\.txt/ & \1.rtf/' | xargs -L1 mv
The above command would run for a whole subdirectory. Depending on where you are in the hierarchy, you could rename all the .txt files on your hard disk! The final command in xargs tells it what to do. You could replace that with something other than mv, like cp or diff; pretty much any command that takes two arguments.
find . -name '*.txt' -print | sed 's/\(.*\)\.txt/ & \1.rtf/' | \ xargs -L1 mv
[robg adds: I haven't tested this one...]
find . -name '*.txt' -print | sed 's/\(.*\)\.txt/ & \1.rtf/' | \ xargs -L1 echo mv
Mac OS X Hints