CloseTurkey
CloseTurkey

Reputation: 55

rsync : Recursively sync multiple file types while ignoring directory structure

Is there a way to make rsync recursively sync multiple file types but not copy the directory structure, just the files?

So far i have got this

  rsync -zarvm --include="*/" --include=*.{xml,properties} --exclude="*" /foo/ /syncdDir/

Which this gives me this

/foo/
    file1.properties
    dir1/
    dir1/file1.xml
    file2.properties
    dir2/
    dir2/file2.xml

What I am looking for is just the file{1,2}.xml and file{1,2}.properties files copied into the /syncdDir/, not the directories dir1 and dir2.

Upvotes: 3

Views: 355

Answers (1)

Mad Physicist
Mad Physicist

Reputation: 114488

You may not be able to flatten the structure with rsync directly, but you could use find to help you do that:

find -type f \( -name '*.xml' -o -name '*.properties' \)
    -exec rsync -zarvm {} /syncDir/ \;

When you use find to do the searching, it's easy to hard-code the output folder to be the same for all inputs.

Upvotes: 1

Related Questions