I have multiple directories whose contents overlap. Sometimes the files are exactly the same, sometimes the names are the same and the contents differ and sometimes files with the same name have different contents. I merge the directories as follows:
$ rsync -aicPb --remove-source-files SOURCE-DIR/ TARGET-DIR/
This command does almost exactly what I want. The problem is that file extensions are not preserved. I.e., the -b
argument causes TARGET-DIR/pictureA.jpg
to be renamed to TARGET-DIR/pictureA.jpg~
, when SOURCE-DIR/pictureA.jpg
is to be copied to TARGET-DIR/
.
Is there any way to preserve file extensions with rsync
when renaming duplicate files? E.g., TARGET-DIR/pictureA.jpg
should be renamed to TARGET-DIR/pictureA~.jpg
.