This should get you started, I added echos so you can see what the script will be doing. Once you are happy with the script remove the echos
Code:
cd /your/external/drive
for FILE in $(find . -type f | grep -e ".m$\|.mat$")
do
THISDIR=`dirname ${FILE} | sed s/"^."//`
echo "mkdir -p /local/drive${THISDIR}"
echo "cp ${FILE} /local/drive${THISDIR}"
done
Good luck,
Hiatt