# common.lib # Note no #!/bin/sh as this should not spawn an extra shell. # It's not the end of the world to have one, but clearer not to. # BASEDIR=/home/steve/example rename() { # expects to be called as: rename .txt .bak [ srcdir/ [ destdir/ ] ] FROM=$1 TO=$2 SRCDIR=$3 DESTDIR=$4 for i in ${SRCDIR}*$FROM do j=`basename $i $FROM` mv $i ${DESTDIR}${j}$TO done } rename .txt .bak /tmp/a/ /tmp/b/