I'm trying to run a batch file that test for 4 different files then based on the correct file present it runs the correct command

0

:: batch file to run backup
@echo off
setlocal
set backup1=="F:\my backups\Disk_1_DataBAckup"
set backup2== "F:\My backups\2_backup_data_to_disk2"
set backup3=="G:\my backups\3_backup_data_to_disk3"
set backup4=="F:\my backups\data_backup_for_disk4"
        if exist %backup1% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:44AD8A39-ADEF-44E6-8CD9-310C8B992E61 
    if exist %backup2% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:7828307B-E0AB-45A5-A7BD-EF2D522A5C3F 
    if exist %backup3% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:B81797C0-B4F0-457B-8644-767584C4B228    
    if exist %backup4% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:E2393AB1-A4A8-4A51-958D-FCEE28715BE0
endlocal

For some reason this doesn't work and I'm not familiar with batch files at all. I'm running Windows 7 (if that mattters) Each day I change the external backup disk and therefore I need the batch file to check to see which drive in attached and then to run the appropriate backup.

Dee McGee

Posted 2014-03-29T05:01:23.950

Reputation: 1

Answers

1

I have only been doing this for about a week, but if I was to approach this I would try it like this

@echo off

IF EXIST "F:\My backups\Disk_1_DataBAckup" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:44AD8A39-      ADEF-44E6-8CD9-310C8B992E61
) ELSE (
ECHO No backup 1
)

IF EXIST "F:\My backups\2_backup_data_to_disk2" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:7828307B-    E0AB-45A5-A7BD-EF2D522A5C3F
) ELSE (
ECHO No backup 2
)

IF EXIST "G:\my backups\3_backup_data_to_disk3" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:B81797C0-    B4F0-457B-8644-767584C4B228
) ELSE (
ECHO No backup 3
)

IF EXIST "F:\my backups\data_backup_for_disk4" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:E2393AB1-    A4A8-4A51-958D-FCEE28715BE0
) ELSE (
ECHO No backup 4
)

pause

EXIT

Donald

Posted 2014-03-29T05:01:23.950

Reputation: 74