Results 1 to 3 of 3
  1. #1
    Star Lounger Doc666's Avatar
    Join Date
    Jan 2002
    Location
    Caledon, Ontario, Canada
    Posts
    89
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Wscript CopyFolder (English)

    Can anyone help me with the Windows Scripting CopyFolder. I am looking for a means to copy newer files only from one folder to another, using windows scripting

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Wscript CopyFolder (English)

    The fileSystemObject.CopyFolder method has only two settings for overwriting existing files: do it, or don't do it. The same is true of the fileSystemObject.CopyFiles method. You may well have to check for the existence in your "destination" folder of every file in your "source" folder and, if it exists, compare the dates. That seems like a lot of coding... might there be some other function or utility available?

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Wscript CopyFolder (English)

    If you run XCopy from a command prompt there is a /D parameter which only copies newer files. It should be possible to run this from script with a Shell object - something like:
    <pre>dim sh
    set sh = WScript.CreateObject("WScript.Shell")
    sh.run "XCOPY C:Test*.txt C:TestTest2 /D /Y", 0, True
    </pre>


    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •