LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to copy files from an entire directory tree using terminal commands??? (https://www.linuxquestions.org/questions/linux-general-1/how-to-copy-files-from-an-entire-directory-tree-using-terminal-commands-433584/)

lusius188 04-10-2006 02:01 AM

How to copy files from an entire directory tree using terminal commands???
 
Hi, I am somewhat new to linux, and was wondering if anyone knew a command or series of commands to copy files from an entire directory tree into a different location.

I understand that find -name *.jpg will find all the *.jpg files on an
entire hard drive if you run it from the root directory.I also understand that the cp command with the -R switch will copy all the files,but just out of one directory into another. I would like the computer to be able to search for an extention such as *.jpg and copy all the *.jpg files to a diff location using command. Any and all help is apreciated.

Thanx...lusius

slackie1000 04-10-2006 03:08 AM

hi there,
your question is weird. do you have more than one target directory? or all .jpg files go to the same dir.
if you have only one target dir, you can check the option exec from find. if you have more than one, you will need a small script.
regards,
slackie1000

lusius188 04-10-2006 09:55 AM

Basically I need the commands to copy *.jpg files from an entire drive so I need to have a script or the commands that will find *.jpg files on the whole drive and copy them no matter where they are into a certain folder.

homey 04-10-2006 11:23 AM

You were on the right track with find. It should look something like this...
Code:

find / -type f -name '*.jpg' -exec cp {} /home/new_folder \;


All times are GMT -5. The time now is 10:48 AM.