5

I am trying to copy files from a folder on a server using a batch file, however, I don't want the files in the destination folder to be overwritten. This is what I have:

set /p address=ip address:
pause
pscp -pw "password" "username"@%address%:/folder path/* c:\folderpath

This works, however, when it runs it overwrites the files in the destination folder. Is there a way to make it skip over the files that are already in the destination folder?

Worthwelle
  • 4,816
jhast1
  • 51

4 Answers4

2

The SCP protocol isn't very sophisticated. The sending side can only blindly send the files and directories to the receiver. There's no standard option to avoid overwriting files on the destination.

You should look at more sophisticated transfer protocols, like SFTP or rsync as in the comments.

Kenster
  • 8,620
0

TL;DR answer from those comments:

rsync -e ssh --ignore-existing server.xxx.com:/path/\* /destination/path

Better yet, if the server also supports CIFS ("network shares"), use that with cp -u.

0

My answer, Filezilla. It can use SFTP protocol, and it's GUI on windows.

https://sourceforge.net/projects/filezilla/

0

Use attrib.exe and set the existing files to read only. This will cause pscp.exe to skip those files.

Boergler
  • 101