Moving files from one remote folder to another while allowing overwriting

Advertisement

rbylnz
Joined:
Posts:
4

Moving files from one remote folder to another while allowing overwriting

I am trying to move files from one remote folder to another remote folder. I am using the mv command and it works fine. The only problem is when there are old files in the destination folder (to be more specific: duplicates of the ones in the source folder), it does not overwrite (or simply skip) those files. The file I want to move still exists in the source folder. The remaining files in the source folder (other than the one that has a duplicate in the destination) also cannot be moved because of this.
I have seen that synchronize local / remote can be used for get / put to overwrite files like this. But I could not find a solution to use for the mv command.
I also tried (instead of using the mv command) copying and then deleting the files between the remote folders, but I couldn't find a command for copying files between remote folders.
Is there a way to solve this?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,276
Location:
Prague, Czechia

Re: Moving files from one remote folder to another while allowing overwriting

There's no simple way to solve this with WinSCP scripting.

You can replace your WinsCP script with e.g. PowerShell script with use of WinSCP .NET assembly.
https://winscp.net/eng/docs/library_from_script
https://winscp.net/eng/docs/library_powershell

With it, you can iterate the files and process then one-by-one doing any checks you need.

Reply with quote

avmaksimov
Joined:
Posts:
5

4 years have passed. Strange but failonnomatch off doesn't work too when I use rm to remove nonexistent file.

I don't understand how to move file with overwriting. Dest file can be exist or not.

Upd. I solved it adding * to filename so failonnomatch started working.

Reply with quote

Advertisement

You can post new topics in this forum