Find the answer to your Linux question:
Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By Roxoff
First, a confession. This is actually a Windows port of rsync I'm using. Still, this question should be valid regardless of operating system. I'm trying to copy only the music ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    18

    rsync only directories containing a certain file type


    First, a confession. This is actually a Windows port of rsync I'm using. Still, this question should be valid regardless of operating system. I'm trying to copy only the music from a large external drive to my laptop hard drive. The command I'm using below works, but with one caveat. It copies every directory regardless of whether that directory contains the files specified. So what I end up with is the folders containing my music, but also a bunch of empty folders. Is there a command that I can add to rsync so that it doesn't copy folders that don't contain these files? If not, is there another (preferably multiplatform) program that will do what I want. Note that in this case I don't need to copy over a network, just local drives. Guess I could write a script but I thought something might already exist and would probably be more efficient. Thanks!

    Code:
    rsync.exe -tr --include "*.mp3" --include "*.flac" --include "*.wav" --include "*.ogg" --include "*.m4a" --include "*.m4b" --include "*.aac" /cygdrive/g/ /cygdrive/d/

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,882
    rsync has the '-m' or '--prune-empty-dirs' option to exclude empty directories. You might also be able to make use of the '--min-size=' option. It's a pretty hefty application when you look at all the things it can do. Take a look at it's man page, if you don't have access to a Linux computer at the mo, stick 'man rsync' into Google.
    spiderdan likes this.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Posts
    18
    Thanks Roxoff. Not sure if I just overlooked that when I originally looked at the manpage or if I didn't know what prune means. Anyway, I seem to be facing a different issue now. EVERYTHING is copying over. I tried to follow the suggestion here (see code below), but, using that method, nothing copies over. Still lost here. Thanks to anyone that can help further!

    Code:
    rsync.exe -trm --include='*.mp3' --include='*.flac' --include='*.wav' --include='*.ogg' --include='*.m4a' --include='*.m4b' --include='*.aac' --exclude='*' /cygdrive/g/ /cygdrive/d/

  4. #4
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,882
    According to the link you posted there is little difference between what they suggest and what you have. Try using 'rsync -avm ...' You could also try dropping the single quotes around each of your include and exclude arguments, I don't know what effect they have in cygwin.
    Linux user #126863 - see http://linuxcounter.net/

  5. #5
    Just Joined!
    Join Date
    Dec 2009
    Posts
    18
    No luck I'm afraid. I've tried this with cwRsync under windows with single, double and no quotes. I also tried rsync under cygwin and even tried rsync under ubuntu with the command below - all with the same result! Everything gets copied without the exclude, nothing with it. Moving the exclude to the front doesn't help either. I'm using rsync 3.0.7 under ubuntu if it's possible this is a version issue. Thanks to anyone that can help!

    Code:
    rsync -trmv --include='*.mp3' --include='*.flac' --include='*.wav' --include='*.ogg' --include='*.m4a' --include='*.m4b' --include='*.aac' --exclude='*' /media/A82CFB922CFB59B0/test/ /media/Storage/
    Edit: using 3.0.7 as cwrsync and 3.0.8 in cygwin. All possess the same problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •