BAT file to copy file to multiple locations?


  1. Posts : 35
    7 Ult x64 sp1
       #1

    BAT file to copy file to multiple locations?


    Hi, I have a file with no extension called simply, D:\file

    I want to copy this to multiple locations, eg e:\file , f:\file

    sometimes there will already be an older version, so I would like it to overwrite the file.


    Is this possible with a bat file?


    I tried a simple copy command in a bat file, but it wouldn't copy at all.



    thanks.
      My Computer


  2. Posts : 1,326
    Windows 7 Ultimate x86
       #2

    Have you tried 'xcopy' with the /y flag. This should copy the files and overwrite without it prompting you.... Would this suut your needs?
      My Computer


  3. Posts : 10,485
    W7 Pro SP1 64bit
       #3

    nevesswodniw said:
    .....I tried a simple copy command in a bat file, but it wouldn't copy at all....
    As long as you have access rights (permissions) to copy to the area of interest, then copy should work just fine. Like pedro said, you will want the "/y" switch on the end to handle overwriting any existing file(s).

    It is probably best to workout the syntax using the command prompt window or include a pause in your batch file so that you can see any errors that might occur:
    BAT file to copy file to multiple locations?-batch-error.png

    BAT file to copy file to multiple locations?-batch1.png

    or with wildcards

    BAT file to copy file to multiple locations?-batch2.png
      My Computer


  4. Posts : 1,326
    Windows 7 Ultimate x86
       #4

    You may find yourself that you would like more "flags" or "switches" which will help refine and customize the xcopy command- here is whee i learned xcopy switches from

    http://ss64.com/nt/xcopy.html
      My Computer


  5. Posts : 35
    7 Ult x64 sp1
    Thread Starter
       #5

    Thanks guys, You helped me with the pause command

    It said cannot find file, so had to use xcopy /h because it is hidden, wouldnt have figured it out without pause.


    Thanks again!
      My Computer


  6. Posts : 10,485
    W7 Pro SP1 64bit
       #6

    thx for posting back.
    glad it is working for you now.
      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 03:25.
Find Us