Rename extensions | filename in bulk

A mysterious virus , had changed the extensions of *.avi to *.jpeg , in on of friends portable harddisk , know the power of Linux , she asked can you write a small code to change the extensions , i gave it a try this way :

for i in *.jpg; do j=`echo $i | cut -d . -f 1`; j=$j".avi"; mv $i $j; done

Further tried to make it more generic

#!/bin/bash old=$(zenity --entry --text="Current extension" --title="Rename") new=$(zenity --entry --text="New extension or name" --title="Rename") for i in *.$old; do j=`echo $i | cut -d . -f 1`; j=$j".$new"; mv $i $j; done zenity --info --text="Done"

Steps in images :



Share this