LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-05-2010, 07:34 AM   #1
sikanders
LQ Newbie
 
Registered: Mar 2010
Posts: 6

Rep: Reputation: 0
Need to copy all .jpg images in subdirectories to a specific directory


Hi All,

I have .jpg files in many subdirectories from where I need to copy all the images from all the sub directories and paste them to a specific directory.

I have used `cp -rf *.jpg media/sik/` which only copies the .jpg files of the directory in which I was working.

Can somebody help me.......!!!
 
Old 08-05-2010, 07:48 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,652

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
Use find.

Code:
find . -name "*.jpg" -exec cp '{}' ./media/sik/ \;
 
1 members found this post helpful.
Old 08-05-2010, 10:14 PM   #3
sikanders
LQ Newbie
 
Registered: Mar 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for reply.....but sorry I forgot to tell you that I need to perform the copy task without using find command...!!!
 
Old 08-05-2010, 11:04 PM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,652

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
why, do you not have find?
 
Old 08-05-2010, 11:15 PM   #5
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,583

Rep: Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226
Do you have zsh?

If yes:
Code:
cp **/*.jpg ./media/sik/
Evo2.
 
1 members found this post helpful.
Old 08-06-2010, 08:15 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
Quote:
Originally Posted by evo2 View Post
Do you have zsh?

If yes:
Code:
cp **/*.jpg ./media/sik/
Evo2.
Newer versions of bash can do that with the "shopt -s globstar" option.

But what of the .jpg file is in the current dir, not in a subdir?
 
1 members found this post helpful.
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to copy specific directory based on variable to folder with that variable name fluxburn Programming 7 01-07-2010 08:59 PM
How to delete all images from a directory/subdirectories SentralOrigin Linux - General 2 04-16-2009 03:54 AM
copy specific files with directory stucture rincewind Linux - Software 1 06-22-2006 08:58 AM
copy 3 files to a directory and all subdirectories? snip128 Linux - Newbie 9 08-12-2005 10:18 PM
How to do recursive file copy of directory for specific files? Arodef Linux - Newbie 4 06-29-2004 06:35 PM


All times are GMT -5. The time now is 07:49 PM.

Main Menu
Advertisement
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