How do I do a selective, recursive copy ? Bash script ?

Peter Langfelder peter.langfelder at gmail.com
Mon Oct 27 21:39:42 UTC 2008


On Mon, Oct 27, 2008 at 12:26 PM, Linuxguy123 <linuxguy123 at gmail.com> wrote:
> I have a huge multi level directory of legally ripped music.   I ripped
> my CDs as flac and mp3.
>
> How do I easily copy just the mp3 files onto another drive ?  Ie, ignore
> the flac files and copy only the mp3 files ?  I want to keep the
> directory structure intact.
>
> The main directory is Music.  In Music is BandA, BandB, BandC, etc.
> Inside BandA is Record1, Record2, Record3, etc.
> Inside Record 1 is song1.flac, song1.mp3, song2.flac, song2.mp3, etc.
>
> I want to preserve the directory structure. I feel a script coming on.
> Am I right ?

Look at the man page for rsync. Basically a command like

rsync -avu --exclude='*.flac' oldDir/ newDir/

should do what you want, that is copy the contents of oldDir into
newDir preserving the directory structure, and it'll preserve
ownership and timestamps as well.

HTH

Peter




More information about the fedora-list mailing list