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

Author Message
247FT
[View user's profile]

Joined: 2011-09-19
Posts: 4
Location: UK
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
How mv behaves is actually server and protocol specific. But in general, it cannot be used to overwrite files.
_________________
Martin Prikryl
247FT
[View user's profile]

Joined: 2011-09-19
Posts: 4
Location: UK
prikryl 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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
_________________
Martin Prikryl
247FT
[View user's profile]

Joined: 2011-09-19
Posts: 4
Location: UK
prikryl 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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Generaly, you need to use script command "option confirm off":
https://winscp.net/eng/docs/scriptcommand_option
_________________
Martin Prikryl
247FT
[View user's profile]

Joined: 2011-09-19
Posts: 4
Location: UK
prikryl 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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
I can tell you more, if post a log file.
_________________
Martin Prikryl
cpaine

Guest


prikryl 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
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License