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 command. 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

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

Advertisement

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:
41,367
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 cpcommand (edit 2021: there's cp command now).

Can you then confirm that option 3. will allow for an overwrite as I can't see it in the switches list for put?
Not needed IMHO, but the option is option confirm off

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, however 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 at least know that there is something waiting to be moved.

Are there any future enhancements to the product with Move (mv) having the overwrite facility?

Thanks, Jay

Reply with quote

Advertisement

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

Re: Move command for overwrite

Jayakanth wrote:

1. Is there a option to overwrite?
No. (2023: There is now, see below)

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:
Emailing script results

Are there any future enhancements to the product with Move (mv) having the overwrite facility?
Sorry, we are not planning that.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Problem overwriting files with mv commant

@tomer: Sorry, indeed, the change was rolled back in the end. You can vote for it to be implemented in the tracker.

Reply with quote

Advertisement

You can post new topics in this forum