I am trying to create an rsync job that syncs src /foo/bar/.jpg to dest /foo/.jpg, skipping mid level directories but preserving the top level. i'm sure there is a way to do this with --include --exclude options but i haven't been able to to figure it out.
This is the src structure;
/Volumes/ExtHDD
└── YYMMDD
├── foo1
│ └── bar
├── foo2
│ └── bar
└── foo3
├── image1.jpg
├── image2.jpg
├── image3.jpg
└── image4.jpg
This is what I'm aiming for at the dest;
/Volumes/OS/Users/user/Dropbox
└── YYMMDD
├── image1.jpg
├── image2.jpg
├── image3.jpg
└── image4.jpg
I have tried;
rsync -avhW --include='*.jpg' --exclude='*' src dest
but it's not even finding the .jpg files so i guess the exclude option is overriding it, however i thought there was an order of operation to the filters.
cp
*.jpg
files anywhere inYYMMDD/
, have a look at unix.stackexchange.com/questions/2161, but AFAIK there's no way to flatten the target directory. The simple solution would be:rsync -avhW src/YYMMDD/foo3/ dest/YYMMDD
.