LinuxQuestions.org
Help answer threads with 0 replies.
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 07-09-2003, 01:34 PM   #1
jesse_mair
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, 01:45 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
just the files? i.e. all lump them in one single directory...? try this from the base directory
Code:
for i in `find . -iname *mp3`
do
   cp $i /destination/`basname $i`
done
 
Old 07-09-2003, 01:54 PM   #3
jpbarto
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
fi
hcaerof

(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, 01:55 PM   #4
jesse_mair
LQ Newbie
 
Registered: Jul 2003
Posts: 3

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


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


All times are GMT -5. The time now is 10:42 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration