using "mv" to transfer files. Force overwrite of dest files

Advertisement

247FT
Joined:
Posts:
4
Location:
UK

using "mv" to transfer files. Force overwrite of dest files

Hi,
I am using a bat file to call winscp.exe using /script switch.
my script contains the command mv to move files from one remote folder to another remote folder on the same server.

mv works fine UNLESS
a) the destination files already exist in which case the equiv source files are not moved.

1. Is there any way when using the mv command to force the target files to always be overwritten so the source files are always "moved"?

I have tried adding the /nopreserve type switches to the mv commandline but without success.

Example commandlines from my script below for reference
cd /Mysourcefolder/Data
mv "*.*" /MyTargetfolder/Data/*.*

Regards

Reply with quote

Advertisement

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

Re: using "mv" to transfer files. Force overwrite of dest files

How mv behaves is actually server and protocol specific. But in general, it cannot be used to overwrite files.

Reply with quote

247FT
Joined:
Posts:
4
Location:
UK

Re: using "mv" to transfer files. Force overwrite of dest files

martin wrote:

How mv behaves is actually server and protocol specific. But in general, it cannot be used to overwrite files.

Hi,
Many thanks for your comment.
I would have though any file transfer program would need to support a switch to force overwriting of files in order to be to be really useful (assuming the server givs you permission to overwrite files) How strange!

Am I correct that winscp in general using get, put, mget, mput etc does have a siwtch to allow you to force overwrite of destination files? If so can you confirm what it is?
I have only found a reference to preserving time stamp that seems to relate to overwriting.

Regards

Reply with quote

martin
Site Admin
martin avatar

Re: using "mv" to transfer files. Force overwrite of dest files

247FT wrote:

Am I correct that winscp in general using get, put, mget, mput etc does have a siwtch to allow you to force overwrite of destination files? If so can you confirm what it is?
Yes, put/get allow overwritting.

Reply with quote

247FT
Joined:
Posts:
4
Location:
UK

Re: using "mv" to transfer files. Force overwrite of dest files

martin wrote:

247FT wrote:

Am I correct that winscp in general using get, put, mget, mput etc does have a siwtch to allow you to force overwrite of destination files? If so can you confirm what it is?
Yes, put/get allow overwritting.

Yeeeeees? Ok..... but as per my origianal message HOW do you force winscp to overwrite? Please advise the switch or switches I need to add and provide a simple example as it isn't clear from any user guides I have seen on line how to do this.
Regards

Reply with quote

Advertisement

247FT
Joined:
Posts:
4
Location:
UK

Re: using "mv" to transfer files. Force overwrite of dest files

martin wrote:

Generaly, you need to use script command "option confirm off":
https://winscp.net/eng/docs/scriptcommand_option

Hi,
Thanks. I had hoped there was something else I had not spotted.
I already have that switch set in my script as well as "option batch on" but the only way I can get the dest file to be overwritten on the remote server appears to be if I add the -nopreservetime switch as well.
With this switch present the file is overwritten on the remote server and the -delete switch causes the local source file to be deleted as required. Otherwise dest file remains unchanged and source file remains in local folder.
I can use other products such as CoreFTP and the file transfers overwrite existing files on the same server without problems so I dont believe it is a specific remote server permissions issue.
Regards

Reply with quote

cpaine
Guest

Re: using "mv" to transfer files. Force overwrite of dest files

martin wrote:

I can tell you more, if post a log file.

I am trying to use winscp to move a file on the remote server to another directory on the same remote server and I cannot get it to work. Here is part of my code:

cd ../../Program Files/WinSCP/
Winscp
option batch on
option confirm off
open xyz.com
username
password
cd directory
mv filename ./NewdirectoryUnderabovedirectory/*.*
exit

Reply with quote

Advertisement

You can post new topics in this forum