Topic "Problem overwriting files with mv commant"

Author Message
rsmallwood
[View user's profile]

Joined: 2011-06-27
Posts: 4
Hi

When I have downloaded files from the remote server, I want to move them to an archive folder on the remote server. I use the mv command to do this as follows:

mv lcenewbkg-*.csv /home/samba/archive-bkgdata/

I have to use a wildcard as the filename is different each day.

The problem is, if one of the files covered by the wildcard already exists in the archive-bkgdata folder, the mv command does not move the files. If I use the GUI to move them manually, I am presented with a message to overwrite the file, but there doesn't seem to be any such option for scripting the mv comment. Am I missing something?

I have 'batch on' and 'confirm off', but I understand these are not relevant for the mv command.

So, how do I get the mv command to always overwrite the files in the remote folder? Or is there another way of doing it?

Thanks

Robin
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
How do you move them in the GUI?
_________________
Martin Prikryl
rsmallwood
[View user's profile]

Joined: 2011-06-27
Posts: 4
I right-click the file and select 'Move to...'

Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
rsmallwood wrote:
I right-click the file and select 'Move to...'

I do not think that "move to" prompts for overwrite. Can you post a screenshot showing that?
Guest




OK - sorry, it was the Copy option which gives the overwrite option. As I understanding it, the Copy function also does not give you the option of overwriting using a command script. If it did, I could also use the CP command followed by the delete command, both using the wildcards.
Guest




I'm not sure how to post a screenshot. Sorry.[/img]
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Anonymous wrote:
As I understanding it, the Copy function also does not give you the option of overwriting using a command script.

option confim off
https://winscp.net/eng/docs/scriptcommand_option
_________________
Martin Prikryl
Chris Guest

Guest


Hi,

Can you confirm the only way to move a file from one remote folder to another then (on same server) with the ability to overwrite is to do the following:

1. get (remote file to local directory)
2. delete (remote file in original directory)
3. put (local file on destination remote directory)

Can you then confirm that option 3 will allow for an overwrite as I can't see it in the switches list for 'Put'?

Could this be some future functionality (a mv with overwrite switch)?

Also what's the CP command that was mentioned? I can't find any references to it?

Cheers
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Chris Guest wrote:
1. get (remote file to local directory)
2. delete (remote file in original directory)
3. put (local file on destination remote directory)

I would do:
1. delete (remote file in destination directory)
2. mv (move remote file from original to destination directory)

There's no CP command.

Quote:
Can you then confirm that option 3 will allow for an overwrite as I can't see it in the switches list for 'Put'?

No needed IMHO, but the option is "option confirm off"
_________________
Martin Prikryl
Jayakanth

Guest


Martin...
We keep getting plenty of files onto our remote server, so on a daily basis we run a batch file to copy and then move the files to the backup folder, howerver whenever there is an existing file, it fails and does not move..
1) is there a option to overwrite?
2) if 1 is not possible; is there a option to send an email (write some script within winscp) saying overwrite failed.

by doing this we would atleast know that there is somewthing waiting to be moved.

are there any future enhancements to the product with Move(mv) having the overwrite facilty.

Thanks, Jay
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Jayakanth wrote:
1) is there a option to overwrite?

No.
Quote:
2) if 1 is not possible; is there a option to send an email (write some script within winscp) saying overwrite failed.

Please read documentation:
http://winscp.net/eng/docs/guide_automation#results

Quote:
are there any future enhancements to the product with Move(mv) having the overwrite facilty.

Sorry, we are not planning that.
_________________
Martin Prikryl
Guest




Try
call mv -f lcenewbkg-*.csv /home/samba/archive-bkgdata/

That will execute the remote command mv with -f switch to force an overwrite.
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