LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-10-2006, 02:01 AM   #1
lusius188
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.

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

Rep: Reputation: 45
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
 
Old 04-10-2006, 09:55 AM   #3
lusius188
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, 11:23 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
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 \;
 
  


Reply


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 11:41 AM
Using wget to copy entire ftp directory stuartmunro Linux - Newbie 7 06-17-2005 07:06 PM
How do I remove an etire directory tree from terminal rickh Fedora 1 04-13-2005 08:05 PM
locate and copy files - without directory tree rodda Linux - General 1 01-16-2005 02:10 AM
How to copy a directory tree without copying the files in it? system Linux - General 2 01-15-2002 09:36 PM


All times are GMT -5. The time now is 03:47 PM.

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