LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 06: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, 06:48 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Use find.

Code:
find . -name "*.jpg" -exec cp '{}' ./media/sik/ \;
 
1 members found this post helpful.
Old 08-05-2010, 09: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, 10:04 PM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
why, do you not have find?
 
Old 08-05-2010, 10:15 PM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

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

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

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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 07:59 PM
How to delete all images from a directory/subdirectories SentralOrigin Linux - General 2 04-16-2009 02:54 AM
copy specific files with directory stucture rincewind Linux - Software 1 06-22-2006 07:58 AM
copy 3 files to a directory and all subdirectories? snip128 Linux - Newbie 9 08-12-2005 09:18 PM
How to do recursive file copy of directory for specific files? Arodef Linux - Newbie 4 06-29-2004 05:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:29 AM.

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
Open Source Consulting | Domain Registration