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.