Saturday, June 27, 2015

Simple shell script to change the extension of multiple files

Below is a simple script that I came up with today since I had to change the extension for a bunch of files. Thanks to original author for the script, I just added interactive touch to it.

for f in *.$1; do
mv -- "$f" "${f%.$1}.$2"
done

The script can be run as below -

./script old_extn new_extn