thefekete.net

$> :(){ :|:& };:

RSync include only certain file types, or exclude all but…

I was recently working on something for my company and needed to transfer all of our product pictures to my home computer. Unfortunately, all the actual product PNGs are intermingled with their corresponding and huge XCFs and other working files. Thus, I needed to exclude all files except the PNGs. Or, to include only the PNGs.

Here’s how to do it:

#!/bin/bash

rsync --include='*/' --include='*.png' --exclude='*' \
–prune-empty-dirs \
example.com:/path/to/source ./

Thanks to Dude for the tip on pruning empty directories. See his Comment below.

I pulled this from here.

2 Responses to “RSync include only certain file types, or exclude all but…”

  1. Dude says:

    use –prune-empty-dirs (-m) or it will create empty directorys of what you didn’t include

  2. Søren Holm says:

    Sweet – just what I needed.

Leave a Reply

HTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting