Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 !

share|improve this question
    
Have you looked at using rsync? –  sreimer Apr 1 '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 1 '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. –  Iain Apr 2 '11 at 11:43

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.