#!/bin/bash

function usage ()
{
    echo "usage : $0 [name_src] name_dest";
    exit;
}

if   test ${#} -eq 2; then
    name_src=${1};
    name_dest=${2};
elif test ${#} -eq 1; then
    name_src="x1_w1_0";
    name_dest=${1};
else
    usage ${*};
fi;

if test ! -d ${name_src}; then
    echo "${name_src} is an invalid directory";
    exit;
fi;

if test ! -d ${name_dest}; then
    mkdir ${name_dest};
fi;
    
for i in ${name_src}/*; do
    sed s/Instance_${name_src}/Instance_${name_dest}/ ${i} > tmp;
    mv tmp ${name_dest}/$(basename ${i});
done
