Help with bat file (xcopy) on Win7


  1. Posts : 3
    windows 7 32bit
       #1

    Help with bat file (xcopy) on Win7


    I have a batch file that copies some files from a win7 hard drive to a USB stick. Sample code:
    mkdir G:\holder
    xcopy C:\users\me\documents\sub\*.*/s/e/h/r/y/D G:\holder\*.*
    This file works fine on any previous version of MS Windows to copy all the files in the targeted directory that are newer than those on the USB and it overwrites them. On Win7, it creates multiple folders (with the same name) each time you run it. So, after running it four times, there are four "holder" files on the USB.

    Any idea why it does this and/or how to correct it?
      My Computer


  2. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #2

    Hi Bob, welcome to the Seven Forums.

    Try Robocopy instead of Xcopy. More here: Batch file copy made easy

    Some examples of using Robocopy can be found in this thread.

    Kari
      My Computer


  3. Posts : 6,285
    Windows 10 Pro X64
       #3

    Try adding /i, see if that makes a difference.
      My Computer


  4. Posts : 3
    windows 7 32bit
    Thread Starter
       #4

    Kari said:
    Hi Bob, welcome to the Seven Forums.

    Try Robocopy instead of Xcopy. More here: Batch file copy made easy

    Some examples of using Robocopy can be found in this thread.

    Kari
    Thanks... that's an option but I'm trying to keep it consistent across platforms and Win2003 doesn't have robocopy.
      My Computer


  5. Posts : 3
    windows 7 32bit
    Thread Starter
       #5

    Ztruker said:
    Try adding /i, see if that makes a difference.

    The /i doesn't look like it has the intended purpose... but I can give it a shot.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:26.
Find Us