If you use the -0 option to xargs , you need to -print0 from find . And, the {} in xargs works only if you specified the replace_string with the -I option.
Note that unless you happen to be sitting in /home/emd/Desktop when you run this script, mkdir will create 1234 in whatever directory you're sitting in; not necessarily /home/emd/Desktop .
It has already been mentioned that if you use -0 on xargs , you need to use -print0 on find ; but neither of these are available on Solaris systems (unless you have the GNU utilities installed). But, unless there are whitespace characters (<space>, <tab>, and <newline>) or quotes (<single-quote> or <double-quote>) in your filenames, you don't need them (and your sample names don't appear to need them).
Since you are using -type f in find , cp won't be given any directories as operands (other than the target directory given as the last operand), the -r option is a no-op.
But, with the xargs -I or -i option, one of which is needed if you don't want xargs to add the pathnames read from standard input to the end of the constructed cp command line; xargs will only pass one pathname from standard input as an operand to cp at a time. So, xargs is a waste of time. A simpler script that should work on both Ubuntu and Solaris systems is: