#!/bin/bash

usage() {
    echo "Error : missing arguments"
    echo ""
    echo "      USAGE : $0 <root_mnt_dir> <old_code> <new_code>"
    echo ""
    echo "Will change the prefix of all files starting with 5XXXX_ to 9YYYY_"
    echo ""
    echo "      ex : $0 /mount/caedirectory 5XXXX 9YYYY "
    echo ""
}
if [ "o$1" == "o" ]
then
    usage
    exit 1
fi
if [ "o$2" == "o" ]
then
    usage
    exit 1
fi
if [ "o$3" == "o" ]
then
    usage
    exit 1
fi

for file in `find $1 -name $2_*`
do
    mv "${file}" "${file/${2}/${3}}"
done
exit 0

