You are not logged in.

#1 2009-11-15 06:36:22

SiegeMachine
Member
Registered: 2009-03-26
Posts: 157

[SOLVED]Copying multiple files from multiple directories to one folder

Title says it all.  I have a discography folder with subfolders of the different years and albums of a band each containing music, some also have more sub folders.  What I want to do is copy all of the music (.mp3's) from all the folders and sub folders into just one music folder.  I found a find and -exec cp command before but it did absolutely nothing for whatever reason.  Perhaps I did it wrong.  Can anyone help me?
Thanks

Last edited by SiegeMachine (2009-11-15 06:54:40)

Offline

#2 2009-11-15 06:45:01

Pox
Member
From: Melbourne, AU
Registered: 2007-10-04
Posts: 66

Re: [SOLVED]Copying multiple files from multiple directories to one folder

mkdir target_dir
find . -type f -exec cp {} target_dir/ \;

Offline

#3 2009-11-15 06:50:06

SiegeMachine
Member
Registered: 2009-03-26
Posts: 157

Re: [SOLVED]Copying multiple files from multiple directories to one folder

Is there a way to make that just mp3 files? I see the . is what its searching for in the name to copy but technically the files came from a windows program and all have a . in them so its copying everything from all the folders into one.  When I put .mp3 though it says no such file or directory.

Offline

#4 2009-11-15 06:52:36

Pox
Member
From: Melbourne, AU
Registered: 2007-10-04
Posts: 66

Re: [SOLVED]Copying multiple files from multiple directories to one folder

. refers to the directory to search (the current directory), it's not a pattern - here's what you want:

find . -iname '*.mp3' -type f -exec cp {} target_dir/ \;

This is assuming you're in the music directory - if not, you want

find /path/to/music -iname '*.mp3' -type f -exec cp {} target_dir/ \;

Last edited by Pox (2009-11-15 06:53:59)

Offline

#5 2009-11-15 06:54:14

SiegeMachine
Member
Registered: 2009-03-26
Posts: 157

Re: [SOLVED]Copying multiple files from multiple directories to one folder

Thanks a lot!

Offline

#6 2009-11-15 06:55:58

Pox
Member
From: Melbourne, AU
Registered: 2007-10-04
Posts: 66

Re: [SOLVED]Copying multiple files from multiple directories to one folder

No problem smile

If your issue has been resolved, adding [SOLVED] to the end of the topic title is informative.

Offline

Board footer

Powered by FluxBB