Problem overwriting files with mv commant

Advertisement

rsmallwood
Joined:
Posts:
4

Problem overwriting files with mv commant

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Problem overwriting files with mv commant

How do you move them in the GUI?
_________________
Martin Prikryl

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Problem overwriting files with mv commant

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?

Reply with quote

Guest

Re: Problem overwriting files with mv commant

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.

Reply with quote

Chris Guest
Guest

Move with overwrite

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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Move with overwrite

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.

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

Reply with quote

Jayakanth
Guest

Move command for overwrite

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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Move command for overwrite

Jayakanth wrote:

1) is there a option to overwrite?
No.
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:
https://winscp.net/eng/docs/guide_automation#results

are there any future enhancements to the product with Move(mv) having the overwrite facilty.
Sorry, we are not planning that.
_________________
Martin Prikryl

Reply with quote

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.

Reply with quote

Advertisement

You can post new topics in this forum