LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to copy all .jpg images in subdirectories to a specific directory (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-copy-all-jpg-images-in-subdirectories-to-a-specific-directory-824339/)

sikanders 08-05-2010 06:34 AM

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.......!!!:(

AlucardZero 08-05-2010 06:48 AM

Use find.

Code:

find . -name "*.jpg" -exec cp '{}' ./media/sik/ \;

sikanders 08-05-2010 09:14 PM

Thanks for reply.....but sorry I forgot to tell you that I need to perform the copy task without using find command...!!!:(

AlucardZero 08-05-2010 10:04 PM

why, do you not have find?

evo2 08-05-2010 10:15 PM

Do you have zsh?

If yes:
Code:

cp **/*.jpg ./media/sik/
Evo2.

MTK358 08-06-2010 07:15 AM

Quote:

Originally Posted by evo2 (Post 4057469)
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?


All times are GMT -5. The time now is 01:13 PM.