Pscp (putty) copy only non-existing files/dirs

batch-fileputty

I'm using PSCP to copy directories from a linux machine to my windows machine.
That works great, but I only want to copy those directories that are new and non existent on my windows machine.

Is there a way to do this? I'm using a windows batch (.bat) file to call pscp.exe so maybe it can be done in the batch file?

Thanks for all advice !

Best Answer

In the unix world, including windows based tools designed to interact with the unix world, tools are generally designed to do exactly one thing and do that thing well. They are typically designed to interact and be combined with other programs to get a job done. SSH is a connection/encryption system. SCP is a way of copying files through SSH. Basically if you ask it to copy something it will. You need another tool on top of that to decide whether or not something should be copied.

The solutions I suggest for you would be to either write your own little script to compare directory trees, or use the program that has already been written for this. It's called rsync and is specifically designed to compare the sets of files and directories in two places and decide which ones need to be copied. It can use scp/ssh as the transport protocol.

There are a number of windows implementations, including guis, independent command line versions and cygwin based versions.