in reply to Is this directory a subdirectory of another directory?

I hope I understand your question correctly.

1. what if you first search for the filenames in one step and prepare the copy-commands file by file, and then i a second step execute the copy-commands?

2. Otherwise:

if ($dir1 !~ /^\Q$dir2/){ print "$dir1 is no subdir of $dir2\n"; }

Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"