I'm trying to copy files with specific attachments to a different directory with their relative paths preserved. From the original top path I am calling:
cp --parents `find . -name \*.pdf -print` /new_path/
I believe this works; however only if the file found has no spaces in the name.
I also tried:
cp --parents `find . -name \*.pdf -print0` /new_path/
This doesn't work obviously because without the new line character cp receives the wrong name.
Is it possible to surround the find result with quotes ?
Try this:
find . -name \*.pdf -print0 | xargs -0 -n 1 -Ifoo cp --parents foo /new_path/
Or
find . -name \*.pdf -exec cp --parents {} /new_path/ \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With