Is there a way to not overwrite existing files when using pscp?

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?

2

2 Answers

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.

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like