Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Questions about synchronize [rename & delete]

Deleting is not supported in the "both" mode. There's no way WinSCP can tell, if a file/folder was added on one side or removed from the other.

Removing is similar. How can WinSCP tell that a file was renamed, vs. one file deleted and another file added.

Both problems would require WinSCP to keep the previous state of files somewhere and compare against that.
IaMa8oY

Questions about synchronize [rename & delete]

Hi

the SFTP server is on remote VPS, winscp app is at local
I am trying to synchronize multiple files and directories at local c:\local\ and remote /D/remote/, both windows OS.
**Both sides {local or remote} may create/delete/edit/rename files or directories at any time**

Existing Folder Structures:
C:\local\                             /D/remote/

        \File_1.txt                            /File_1.txt
        \File_2.txt                            /File_2.txt
        \Folder_A\                             /Folder_A/ 
        \Folder_A\File_A1.txt                  /Folder_A/File_A1.txt         
        \Folder_A\File_A2.txt                  /Folder_A/File_A2.txt             
        \Folder_B\File_B1.txt                  /Folder_B/File_B1.txt     
        \Folder_B\File_B2.txt                  /Folder_B/File_B2.txt

Synchronize Code:
option batch abort
option confirm off
open sftp://user:pass@ip:port -hostkey="ecdsa-sha2-nistp384 384 c8:53:70:a4:1b:79:8b:10:0c:5e:9b:45:95:76:33:be"
synchronize both C:\local\ /D/remote/
exit


Create and Edit works without issue.
Create:
When I create files and folders on both sides, it syncs to the other side. So create is all good with the above code.

Edit:
When I edit something in File_B2.txt on both sides, it syncs to the other side. So Edit is all good with the above code.

Delete and rename doesn't work as expected.
Delete:
When I delete files and folders on both sides, it wont delete on the other side.
eg: Steps
.......1) delete folder C:\local\Folder_B
.......2) run the above synchronize Code
it will
.......1) download Folder_B from remote to local

Code: synchronize -delete remote C:\local\ /D/remote/ will work with the above situation.
But it fails if user delete files or folders on remote server first.

Rename:
When I rename files and folders on both sides, it wont rename on the other side.
eg:Steps:
.......1) rename File_1.txt to File_3.txt at Local C:\local\ folder.
.......2) run the above synchronize Code
it will
.......1) download File_1.txt from remote to local
.......2) upload File_3.txt from local to remote
Not sure how to achieve rename with synchronize, when I test keepuptodate it works.

How to code it to make delete and rename work at any time?

Thanks for your help.