Set oShell = CreateObject("WScript.Shell")
strCommand = oShell.Run("Xcopy ""p:\"" ""d:\12"" /S /Y", 0, True)
If strCommand <> 0 Then
MsgBox "Error: Not_Copy" & strCommand
Else
MsgBox "Copy_Done"
End If
I use above vb script to copy all my data from a pen drive to "d:\12" folder. I have one problem with it.
Many times, I have same files with same folder path in the pendrive, like "java-setup.exe" in "p:\" also and also in "d:\12". When I play this VBScript file, it replaces all the files, and lots of time is wasted.
Is there any option which makes it it stop replacing files (skip already copied files), and focus on only those files which are not copied?
I am new in scripting, beginner level. so please give direct coding, not like this,
$srcdir = "\\server\source\";
$destdir = "C:\destination\";
$files = (Get-ChildItem $SrcDir -recurse -filter *.* | where-object {-not ($_.PSIsContainer)});
$files|foreach($_){
if (!([system.io.file]::Exists($destdir+$_.name))){
cp $_.Fullname ($destdir+$_.name)
};
Many times i can't understand it.
My pen drive path is "p:\" and files where i have to copy is "d:\12"
please, provide script.