Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
john924xps
- Posts: 65
- Joined: 08 Jun 2012 07:48
#1
Post
by john924xps » 12 Nov 2012 08:01
I have followed all the advice you guys gave me. But my program still doesn't work... so I have given up all hope. This is the piece of code I need help with:
Code: Select all
@echo off
title Backup
color 0a
setlocal enableDelayedExplansion
:varset
cls
set location=
set destination=
set agree=
echo Enter a location and destination or simply type save
echo to add and create paths to inherit from.
set /p location=Location of file/folder:
if /i "%location%"=="save" (
set save=location
goto save)
set /p destination=Destination to copy to:
if /i "%destination%"=="save" goto save
echo.
echo Location: %location%
echo Destination: %destination%
echo Agree?
set /p agree=(yes/no):
if /i "%agree%"=="no" goto varset
if not exist "%destination%\BackupMainDir" md "%destination%\BackupMainDir"
set checknum=1
:checkfunc
if exist "%destination%\BackupMainDir\Backup %checknum%" (
set /a checknum=%checknum% + 1
goto checkfunc) else (
md "%destination%\BackupMainDir\Backup %checknum%"
xcopy "%location%\*.*" "%destination%\BackupMainDir\Backup %checknum%" /s /h /e /k /f /c 2>nul
xcopy "%location%.*" "%destination%\BackupMainDir\Backup %checknum%" /s /h /e /k /f /c 2>nul
pause
goto :eof)
:save
cls
set stringload=
set new=
if exist "%appdata%\BackupSaves.txt" (
echo How many strings do you want to load?
set /p stringload=::
cd "%appdata%"
//PROBLEM STARTS HERE
<BackupSaves.txt (
for /l %%G in (0,1,!stringload!) do (
set /p _save%%G=)))
cls
echo Select a variable to inherit or type "new" to create a new list...
set _save
echo.
set /p select=::
if /i "%select%"=="new" (
echo.
set /p new=New Address:
cd %appdata%
if not exist "BackupSaves.txt" (
echo %new% > "BackupSaves.txt") else (
echo %new% >> "BackupSaves.txt")) else (
if "%save%"=="location" (
set location=%select%) else (
set destination=%select%))
goto varset
Last edited by
john924xps on 18 Nov 2012 21:40, edited 2 times in total.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#4
Post
by foxidrive » 18 Nov 2012 23:23
Put pause commands in and see where it fails - you didn't say what it does or doesn't do.
-
Aacini
- Expert
- Posts: 1914
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#5
Post
by Aacini » 19 Nov 2012 05:19
"ExpLansion"? This makes that all expansions that use ! will NOT work...
Where is the ":save)" label located? It does NOT exist (just ":save")... The same happen with "checkfunc" and "eof"
This does NOT work for the reasons I explained at
this postNote that this line:
does NOT close any previous block...
The same happen three times more.
--> Place closing parentheses in separated lines!!! ie:
Antonio
-
john924xps
- Posts: 65
- Joined: 08 Jun 2012 07:48
#6
Post
by john924xps » 19 Nov 2012 06:15
Thanks, guys. And I have always assumed that we didn't have to use a colon in the goto command.... thanks anyways!
-
Aacini
- Expert
- Posts: 1914
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#7
Post
by Aacini » 19 Nov 2012 09:20
The problem is NOT the colon, but the parentheses!
is wrong,
UNLESS you have this label placed in other line:
A general problem with your code is the place where you put closing parentheses!!!
On the other hand, you may use GOTO LABEL or GOTO :LABEL if you wish, they both are exactly the same...
Antonio