0

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 !

solsol
  • 1,121
  • 8
  • 21
  • 31
  • Have you looked at using rsync? – sreimer Apr 01 '11 at 18:06
  • yes, but we'd just like to use pscp because we are only copying over directories. Everything works perfect this way, we just need a way to check if a directory exists or not, nothing more. Thanks for the suggestion! – solsol Apr 01 '11 at 18:28
  • What you want to do is non trivial. Now is the time to start using the correct tools for the job. – user9517 Apr 02 '11 at 11:43

1 Answers1

1

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.

Caleb
  • 11,813
  • 4
  • 36
  • 49