Getting rsync to move file from source to destination?

Solution 1:

If you really want to use rsync, it sounds like you'll need some combination of --backup, --backup-dir, and --suffix. The closest I think you could get is with something like this

rsync -abv --suffix R1 --remove-source-files src/ dst/

This would do close to what you want, but it would not rename the files exactly the way you'd want. The --suffix option appends text to the end of an existing file, but it only does this for the first conflict. If you ran it again, it would just overwrite your first backup. You'd have to change that suffix value each time the command ran, which would work if you used something with a timestamp, such as this:

rsync -abv --suffix `date +%Y%m%d%k%M%S` --remove-source-files src/ dst/

I'm not sure if this is overkill for what you're after, but it should meet your requirements.

Solution 2:

As the name implies, rsync is used for synchronizing files. When "synced", this means that the files on the source and destination are the same. That does not seem like what you want to do.

It seems like you just want to move some files. You don't need to use rsync for that. It seems like you are using a linux or BSD. You could use mv -n over ssh. The -n option does not overwrite existing files. This is not 100% automatic. However, I don't see how the file could already exist in your case. The files will be copied from the source to the destination and then removed from the source. Do you want to run the same calculations again? Is that why you will end up with files with the same name? I'd suggest appending a run or batch number to the folder name. You'd want that to be clear anyway. Do you have any control over how the folder is named? Any more details? I'd recommend putting the commands in a bash script or similar.