in reply to copy and rename depending on location

For such a simple task, I'd probably use just bash:
cd /test1/da/ for file in */*/*.dat ; do mv $file /newfolder/${file////_} done