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:\folderpathThis 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?
22 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.