Rename file if file exist on remote

I have 2 folders and use the "move" command for transport files from source to destination. Everything is working fine. But I have a problem if a file exists in the destination. I need to rename the file if the same file names are in the destination,and then move the destination

In general, if there is a similar file in the destination, the file should not be replaced, but renamed and placed in the destination

hello and welcome to the forum,

might try

not exactly sure what you are asking help with, a detailed example would be helpful.

I try this solution but not work

briefly Suppose :
file "a.txt" exists in destination and then copy a.txt in the source folder then run rclone. normally a.txt replace a.txt in the destination but in need instead of the replace file for example a.txt rename to a(2).txt and then move to the destination.

  • what if a(2).txt already exists in the dest?
  • what set of rules do you expect rclone to use to rename the source file?

rclone moveto can move a source file to the dest with a different file name.

Why not do something like

--suffix `date '+.%Y%m%dT%H%M%S'` --suffix-keep-extension

It won't do a(2).txt but will do a.20211209T093108.txt

1 Like

Very thanks
Work fine :slight_smile:

@jwink3101, @bahman_jafari,

i had thought of that, did testing, could not get it working.

can both of you, share the exact command that would move+rename files from source to the dest, without touching existing files in the dest?
hopefully you can post a debug log.

thanks,

Hmm. You're right. That will move the old file, not the new with the new name.

I wonder if it can be hacked with --copy-dest but I can't test it right now. Sorry I misread the original question.

in some cases, rclone will not transfer the file from source to dest.
for example, if the source and dest have the same hash, but different modtime, then rclone will

  1. update the modtime of dest file
  2. delete the source file

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.