How to make a multible copy batch file


  1. AGB
    Posts : 16
    Windows 7 Home Premium 64 bit
       #1

    How to make a multible copy batch file


    Below is a batch file I created to copy all the files from a program called A5V5. This batch file works to copy the files to two different drives What I want to do is if the J: Directory is not availble (This is a flash drive) that it will copy to the E:\ directory which is a second HDD and not leave a "The system cannot find the drive specified" when the flash drive is not inserted.

    @echo off
    cd c:\
    cd program files (x86)
    cd A5V5
    cd Ranch Mobile, Inc
    Copy *.* "E:\Ranch Mobile" (This is a second hard drive for backup files only)
    Copy *.* "J:\Ranch Mobile" (This is a Flash drive that is not always inserted)
    Pause

    Thanks for any help. I like the way batch files work and I can do these simple ones but when it comes to doing the more complicated ones I am at a total loss.
      My Computer


  2. Posts : 2,177
    Windows 8.1 Pro x64
       #2

    Hi AGB,

    Welcome to Seven Forums.

    Can you try the following and see if this works:
    Code:
    @echo off
    cd "c:\program files (x86)\A5V5\Ranch Mobile, Inc"
    
    Copy *.* "E:\Ranch Mobile"
    
    IF EXIST J:\ (goto jdrive) ELSE (goto end)
    
    :jdrive
    Copy *.* "J:\Ranch Mobile"
    
    :end
    Pause
    This will always copy to your fixed E:\ drive and will only copy to your J:\ drive when exists.
    Is this what you wanted?

    Regards,
    JDobbsy1987
      My Computer


  3. AGB
    Posts : 16
    Windows 7 Home Premium 64 bit
    Thread Starter
       #3

    Thanks For very fast response. It works Just fine. I put a pause after the first copy command under the E:/ drive line to see it work with or without the flash drive.
    Never being on a forum before I figured since Batch files are rarely mentioned anymore that it would be a few days if at all for a response.
      My Computer


  4. Posts : 2,177
    Windows 8.1 Pro x64
       #4

    I'm glad i could be of help.

    If the J:\ drive doesn't exist then it will just skip it and move on so you shouldn't see any errors :)
    I use batch files all the time

    If you need any more help don't hesitate to post back here, Seven Forums is a wonderful place

    Regards,
    JDobbsy1987
      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 01:52.
Find Us