Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 04-10-2006, 03:01 AM   #1
LQ Newbie
Registered: Jan 2006
Posts: 2

Rep: Reputation: 0
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.

Old 04-10-2006, 04:08 AM   #2
Senior Member
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
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.
Old 04-10-2006, 10:55 AM   #3
LQ Newbie
Registered: Jan 2006
Posts: 2

Original Poster
Rep: Reputation: 0
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.
Old 04-10-2006, 12:23 PM   #4
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
You were on the right track with find. It should look something like this...
find / -type f -name '*.jpg' -exec cp {} /home/new_folder \;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy an entire directory structure except certain files? thanhvn Programming 9 01-27-2012 12:41 PM
Using wget to copy entire ftp directory stuartmunro Linux - Newbie 7 06-17-2005 08:06 PM
How do I remove an etire directory tree from terminal rickh Fedora 1 04-13-2005 09:05 PM
locate and copy files - without directory tree rodda Linux - General 1 01-16-2005 03:10 AM
How to copy a directory tree without copying the files in it? system Linux - General 2 01-15-2002 10:36 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration