msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

17 Feb 2008 Rename file extension recursively

Posted by

This is a simple bash script to rename all JPG file extensions to JPEG, it works recursively and takes subfolders also.

#!/bin/bash

function rename_extension
{
        #change all .jpg to .jpeg
        for file in $1/*.jpg; do
                mv $file $1/`basename $file .jpg`.jpeg;
                echo $file;
        done;

        # recurse directories
        for d in $1/*; do
                if test -d $d; then
                        rename_extension $d;
                fi;
        done;
}

dir=`pwd`;

rename_extension $dir;

Tags: ,

Comments are closed.