Link to home
Start Free TrialLog in
Avatar of chobus
chobusFlag for United States of America

asked on

VB Script to copy files if file doesn't exist in target directory.

I found this code that someone posted and it works great except I want to make it copy all sub folders and files with file ownership and ACL information. Can this even be done?


Const strSOURCE = "c:\test\"
Const strTARGET = "c:\test-2\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fol = fso.GetFolder(strSOURCE)
For Each fil in fol.Files
    If (Not fso.FileExists(strTARGET & fil.Name)) Then
         fso.Copyfile strSOURCE & fil.Name, strTarget, true          
    End If
Next

MsgBox lngCount & " files copied", vbInformation , "Image Copy Complete"
Avatar of chandru_sol
chandru_sol
Flag of India image

I think it is better to use Robocopy from Microsoft for copying data which will copy with ACL's

Give it a try
Avatar of chobus

ASKER

What is Robocopy? Can it copy to Network Drives?
ASKER CERTIFIED SOLUTION
Avatar of chandru_sol
chandru_sol
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chobus

ASKER

How do I get Robocopy? I didn't see a download at http://www.ss64.com/nt/robocopy.html
Avatar of chobus

ASKER

I found a Windows Server 2003 Resource Kit Tools that has it but what can I do for Windows server 2000?
You can download the resource kit for windows 2003 as robocopy is part of it.

Robocopy GUI can be downloaded here

http://www.microsoft.com/technet/technetmag/issues/2006/11/UtilitySpotlight/