How to make a multible copy batch file

AGB

New member
Local time
8:28 PM
Messages
16
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

Computer Manufacturer/Model Number
Custom Built
OS
Windows 7 Home Premium 64 bit
CPU
AMD Phenom X4 9750 2.4Ghz 4MB OEM CPU
Motherboard
MSI 785GTM-E45 AMD 785G Socket AM2+ Motherboard Model MS-754
Memory
4 GB Patriot Signature 2048MB DDR2 800MHz (2)
Graphics Card(s)
ATI Radeon HD4200 On Board
Sound Card
Chip integrated by Realtek ALC888S
Monitor(s) Displays
Samsung SyncMaster 933
Hard Drives
Seagate 500 GB Serial ATA
PSU
Power Up LT 400w ATX
Case
Diablotek EVO CPA-6170 Mid-Tower
Cooling
Zalman Ultra Quiet Cooler CNPS7000V(AL)-I-PWM
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self Built
OS
Windows 8.1 Pro x64
CPU
Intel Core i5-2500K @ 3.30GHz - S1155
Motherboard
Asus P8P67 LE Rev3, Intel P67, S115
Memory
8GB Corsair DDR3 XMS3, PC3-12800
Graphics Card(s)
NVIDIA GeForce GTX 650
Sound Card
On-Board
Monitor(s) Displays
3 x 24" {Extended Display}
Screen Resolution
1920 x 1080
Hard Drives
300GB Seagate Barracuda 7200
PSU
550W Coolermaster GX550
Case
Silverstone Precision PS04B
Cooling
Stock
Keyboard
Logitech K120
Mouse
World of Warcraft Cataclysm MMO Gaming Mouse
Internet Speed
80 MB
Antivirus
MSE / Windows Defender
Browser
Chrome
  • Like
Reactions: AGB
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

Computer Manufacturer/Model Number
Custom Built
OS
Windows 7 Home Premium 64 bit
CPU
AMD Phenom X4 9750 2.4Ghz 4MB OEM CPU
Motherboard
MSI 785GTM-E45 AMD 785G Socket AM2+ Motherboard Model MS-754
Memory
4 GB Patriot Signature 2048MB DDR2 800MHz (2)
Graphics Card(s)
ATI Radeon HD4200 On Board
Sound Card
Chip integrated by Realtek ALC888S
Monitor(s) Displays
Samsung SyncMaster 933
Hard Drives
Seagate 500 GB Serial ATA
PSU
Power Up LT 400w ATX
Case
Diablotek EVO CPA-6170 Mid-Tower
Cooling
Zalman Ultra Quiet Cooler CNPS7000V(AL)-I-PWM
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 :D

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

Regards,
JDobbsy1987
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self Built
OS
Windows 8.1 Pro x64
CPU
Intel Core i5-2500K @ 3.30GHz - S1155
Motherboard
Asus P8P67 LE Rev3, Intel P67, S115
Memory
8GB Corsair DDR3 XMS3, PC3-12800
Graphics Card(s)
NVIDIA GeForce GTX 650
Sound Card
On-Board
Monitor(s) Displays
3 x 24" {Extended Display}
Screen Resolution
1920 x 1080
Hard Drives
300GB Seagate Barracuda 7200
PSU
550W Coolermaster GX550
Case
Silverstone Precision PS04B
Cooling
Stock
Keyboard
Logitech K120
Mouse
World of Warcraft Cataclysm MMO Gaming Mouse
Internet Speed
80 MB
Antivirus
MSE / Windows Defender
Browser
Chrome
Back
Top