I've learned to use the find command by itself to find files and directories however when it comes to doing something with the files/folders I'm confused.
Given the following command:
find . -type f -iname "*.cr2"
If I want to copy those files found above to a new directory I would naturally think use copy (cp) and pipe |.
find . -type f -iname "*.cr2" | cp \destination_directory
And to me this would get all my photos across an entire drive and nested in levels of sub folders into a single folder ready to start organising.
However people keep telling me to use the -exec parameter, so my question is how do you know when to pipe | and when to use -exec command as below?
find . -name "*.pdf" -type f -exec cp {} ./pdfsfolder \;
EDIT
The suggested solution (below) only copies files where the file names are unique. and it says cp will not copy file.txt and replace with file.txt. In the instance you copy a lot of files, and don't know if there will be files of the same name, how do you copy something and say rename it if the filename exists?
Suggested solution "find . -type f -iname "*
find . -type f -iname "*.txt" -print0 | xargs -0 cp -t /home/josh/Documents/copy/
/home/josh/documents/copy being the directory I want to move stuff to.txt" | cp \destination_directory"