How to port this *nix-shell script to OS X?
Have a look at this SO thread: https://stackoverflow.com/questions/11246070/cp-parents-option-on-mac

cp is available on OS X, but it does not support the --parents option, as I guessed. Instead of using cp --parents, replace it with ditto as mentioned in the SO answer.