Home rsync: Sync all files to single directory, ignoring directory structure
Reply: 1

rsync: Sync all files to single directory, ignoring directory structure

Cory
1#
Cory Published in 2016-05-07 22:46:56Z

I would like to sync all files to a certain directory without syncing the directory structure.

So far, I have this:

rsync -vcr --remove-source-files --exclude='*sample*' --exclude='*Sample*' --include='*/' --include='*.avi' --include='*.mkv' --include='*.mp4' --include='*.wmv' --exclude='*' $src1 $src2 $dest

That seems to be working fairly well, but if one of the included file types are in a sub-directory of the source directories, the parent directories will also be transferred.

To sum it up, I want all included file types to be moved straight to the single destination directory, WITHOUT copying the parent directory structure.

J. Chomel
2#
J. Chomel Reply to 2016-05-15 06:38:12Z

It looks like you have an extra --include='*/ in your command that is not needed, and causing the issue you experience. You should go for the below:

Edit

Let's also remove the --exclude='*' which might be redundant since we use include for the relevant files.

rsync -vcr --remove-source-files --exclude='*sample*' --exclude='*Sample*'        \
      --include='*.avi' --include='*.mkv' --include='*.mp4' --include='*.wmv'     \
      $src1 $src2 $dest

Hope it helps.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.300151 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO