Copy contents of one file to another

I need to write a script (in bash) that copies the content of the first file in each folder of a directory to the second file in the same folder. I tried this and it didn't work - it just came back with errors and I'm not sure how to fix it. Help is very much appreciated!

for mpdir in ${PWD}/000*/*[Aa]*; do 
firstmat=`ls  ${mpdir}/*.mat|head -1`; 
cp ${firstmat} tmp; 
for f in ${mpdir}/*.mat;  do cp tmp ${f}; done; 
rm tmp; \
done

The "first" and "second" file are identified by what means? Sorted alphabetically, by date, unsorted i.e. directory entry order?

The first and second file have the same name, with the exception that the first file has 004 in the name and the second has 005. So yes, numerically.

So ls *004* would yield a list of the files to be copied? If not, please provide the directory / file structure to give me a chance to understand.

Why not just do cp -r source dest?

/tmp/cp_test >tree a
a
b
** x
** ** t1
** y
c
** t2
d

5 directories, 2 files
/tmp/cp_test >tree a2
a2
b
x
tt

3 directories, 0 files
/tmp/cp_test >cp -r a2/b a
/tmp/cp_test >tree a
a
b
** x
** ** t1
** ** tt
** y
c
** t2
d

So cp -r will copy the directory if it does not exists, and add files if directory exists, overwrite file, if file exists.