Quote:
cp -R /directory/you/want/to/copy/from/*.ext /new/destination
|
Guess I'm missing something here because that ain't working for me.
The part that acts goofy is selecting just some file types. It works ok to copy everything like this...
cp -r /home/images/* /home/new_dir
But if I try to select just the jpg files, it only copies the jpg files which are in the /home/images and not the sub directories or files. For example...
cp -r /home/images/*.jpg /home/new_dir
I did find a couple of work arounds but I would like to know what I'm missing on the original cp -r command.
Example 1
Code:
#!/bin/bash
cd /home/images
find . -depth -type f -name '*.jpg' | cpio --pass-through \
--preserve-modification-time \
--make-directories --verbose /home/new_dir
Example 2
Code:
#!/bin/bash
cd /home/images
find . -type d -name '*' -exec mkdir -p /home/new_dir/{} \;
find . -type f -name '*.jpg' -exec cp {} /home/new_dir/{} \;