Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-09-2003, 12:34 PM   #1
LQ Newbie
Registered: Jul 2003
Posts: 3

Rep: Reputation: 0
cp command question .

I have a bunch of mp3's in tons of folders on cd's . I want to copy each mp3 from all the folders using a comand line to a folder on the hard drive . ( i.e. only the files , not the folders )

@: cp *.mp3 mymp3folder

but this will only copy the mp3's in the root directory of the cd drive , not everything inside all the folders .

any help would be great , or even a direction on where to look .
thank you kindly =)
Old 07-09-2003, 12:45 PM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
just the files? i.e. all lump them in one single directory...? try this from the base directory
for i in `find . -iname *mp3`
   cp $i /destination/`basname $i`
Old 07-09-2003, 12:54 PM   #3
Senior Member
Registered: Mar 2003
Location: Pittsburgh, PA
Distribution: Gentoo / NetBSD
Posts: 1,251

Rep: Reputation: 45
Ahh Daniel-san. You must write Bash script. Let me get this straight ... you want to recursively copy mp3 files from subdirectory upon subdirectory and dump all those files into ONE directory on another disk correct?

(linux guru's tell me if I do wrong)
I think the quickest way would be to write some bash script that can be executed from the command line...

something like this:

foreach file in `ls -R`; then
if [ -d $file ]; then
cp $file/*.mp3 mymp3dir

(that is probably a horribly wrong doesn't-even-look-like-bash bash script. I haven't had to write script for some time. However it is possible. Essentially you need to retrieve a listing of all subdirectories and then for each subdirectory execute your copy command. pretty simple in theory... just a matter of finding the right commands.
Old 07-09-2003, 12:55 PM   #4
LQ Newbie
Registered: Jul 2003
Posts: 3

Original Poster
Rep: Reputation: 0
thanks guys .. i'll give that a go ,,...


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
Question About a Command? carlosinfl Linux - General 4 10-28-2005 12:51 PM
Command question satimis Linux - Newbie 2 11-24-2004 08:59 AM
Command question satimis Linux - General 8 06-23-2004 02:43 AM
cp command question satimis Linux - Newbie 1 09-13-2003 08:31 PM
Command Question gauge73 Linux - Newbie 2 02-13-2003 08:18 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:21 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