Advice regarding my batch script?

Soldato
Joined
23 Mar 2007
Posts
2,553
Location
Essex
Hi all just looking for some advice regarding my batch script i have created. I have added a goto menu to the script so it will ask which backup drive i want to backup files to. I have set it to go to backup drive 1 upon the number 1 being pressed and backup drive 2 upon the number 2 being pressed. The problem i have is whenever i press the number 2 option to backup to backup drive 2 it seems to go to the backup drive 1 menu instead of the backup drive 2 menu :confused:

Sorry if i sound confusing, i have put the script below for you to see.

Hope someone might be able to help



ECHO WHICH BACKUP DRIVE WOULD YOU LIKE TO BACKUP YOUR FILES TO?

ECHO ------------------
ECHO BACKUP DRIVES LIST
ECHO ------------------
ECHO 1. BACKUP DRIVE 1
ECHO 2. BACKUP DRIVE 2

ECHO.

SET /P N=TYPE 1 FOR BACKUP DRIVE 1 OR 2 FOR BACKUP DRIVE 2 THEN PRESS ENTER:
IF "%N%"=="1" GOTO BACKUP DRIVE 1 WIZARD
IF "%N%"=="2" GOTO BACKUP DRIVE 2 WIZARD

:BACKUP DRIVE 1 WIZARD

ECHO ----------------
ECHO MY MOVIES BACKUP
ECHO ----------------

ECHO THE FOLLOWING FILES WILL BE COPIED FROM MEDIA DRIVE 1 TO BACKUP DRIVE 1
XCOPY "D:\My Movies" "\\LIAM-MEDIA\Backup Drive 1\Movies" /L /D /Y /S
PAUSE
XCOPY "D:\My Movies" "\\LIAM-MEDIA\Backup Drive 1\Movies" /S /D /Y
ECHO.

ECHO THE FOLLOWING FILES WILL BE COPIED FROM MEDIA DRIVE 2 TO BACKUP DRIVE 1
XCOPY "F:\My Movies" "\\LIAM-MEDIA\Backup Drive 1\Movies" /L /D /Y /S
PAUSE
XCOPY "F:\My Movies" "\\LIAM-MEDIA\Backup Drive 1\Movies" /S /D /Y
ECHO.


:BACKUP DRIVE 2 WIZARD

ECHO ----------------
ECHO MY MOVIES BACKUP
ECHO ----------------

ECHO THE FOLLOWING FILES WILL BE COPIED FROM MEDIA DRIVE 1 TO BACKUP DRIVE 2
XCOPY "D:\My Movies" "\\LIAM-MEDIA\Backup Drive 2\Movies" /L /D /Y /S
PAUSE
XCOPY "D:\My Movies" "\\LIAM-MEDIA\Backup Drive 2\Movies" /S /D /Y
ECHO.

ECHO THE FOLLOWING FILES WILL BE COPIED FROM MEDIA DRIVE 2 TO BACKUP DRIVE 2
XCOPY "F:\My Movies" "\\LIAM-MEDIA\Backup Drive 2\Movies" /L /D /Y /S
PAUSE
XCOPY "F:\My Movies" "\\LIAM-MEDIA\Backup Drive 2\Movies" /S /D /Y
ECHO.
 
I think i might have found the issue, it didnt seem to like the spaces on the goto menus so i just changed backup drive 1 wiazrd to drive1 and backup drive 2 wizard to drive2 and it seems to now go to the correct menu
 
Tried a few things, ended up being the spaces as you said ^

Code:
@ECHO OFF
ECHO WHICH BACKUP DRIVE WOULD YOU LIKE TO BACKUP YOUR FILES TO?

ECHO ------------------
ECHO BACKUP DRIVES LIST
ECHO ------------------
ECHO 1. BACKUP DRIVE 1
ECHO 2. BACKUP DRIVE 2

ECHO.

:MENU

>$$$.vbs echo wsh.echo inputbox("TYPE 1 FOR BACKUP DRIVE 1 OR 2 FOR BACKUP DRIVE 2 THEN PRESS ENTER:")
for /f "tokens=*" %%a in ('cscript//nologo $$$.vbs') do (
	set option=%%a
)
IF %option% ==1 GOTO BACKUPDRIVE1WIZARD
IF %option% ==2 GOTO BACKUPDRIVE2WIZARD2
echo Invalid response..
GOTO MENU

:BACKUPDRIVE1WIZARD

ECHO ----------------
ECHO MY MOVIES BACKUP 1
ECHO ----------------

GOTO:EOF

:BACKUPDRIVE2WIZARD2

ECHO ----------------
ECHO MY MOVIES BACKUP 2
ECHO ----------------

GOTO:EOF
 
Use robocopy instead of xcopy.

Robocopy /e "c:\ source" "d:\ destination"

Only copies new or updated files.




Remove the spaces ie..

goto backup1


Then in the code after backup1, add

goto end

Then chuck in ":end" at the end of the file
 
Last edited:
Thanks both of you much appreciated, i might look into robocopy as i know xcopy is a little dated now :)

One thing i would like to know if you might be able to lend a hand. Bascially i now have 2 backup drives and i wanted to carry on backing my movies up to my new backup drive as the old one is now full. You can see the basic copy command i use to copy my movies to my old backup drive whcih was fine but what i would like to do is be able to copy only the new movies i add to my collection to the new backup drive but i cant seem to find a way of doing it. If i setup the new drive with the script above for example its going to copy all my movies again that i already have on the other backup drive from my media machine, all i want is the ones that are not currently on the old backup drive to be copied to the new backup drive

Is this possible do you think?
 
Yea i know pal lol i just bought a 2tb external hd just transfering 800gb of files now gonna take 5 hrs lol typical slow usb 2 external drives hey!
 
I used to do A LOT of batch scripts in my old job as a CAD technician and I used to have similar problems regularily regarding spaces, another common one to watch out for aswell is when your file paths start to get quite long, as the problem I used to have is it would only read a file path upto a certain amount of characters and to get around this we had to use a "wildcard" to blank out the common area of filepaths, used to take longer but used to save us time rather than doing it manually.

hope this is useful :) and if not at least I tried :D
 
Back
Top Bottom