Change extension of many files using bash

Sometimes I need to rename a bunch (thousands) of file extensions. Doing this manual is really not feasible, so after some digging I found this solution:

for filename in *.MQ; do mv $filename `basename $filename .MQ`.XML; done

This snippet finds all files with the extension ‘MQ’ in your current folder and renames them with the extension ‘XML’.

Can be run directly on the command line in most *nix variants. Tested on Red Hat Enterprise Linux AS release 3 (Taroon Update 9)

Comments are closed.