Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
john924xps
- Posts: 65
- Joined: 08 Jun 2012 07:48
#1
Post
by john924xps » 01 Nov 2012 23:13
This is my program:
Code: Select all
@echo off
title Backup
color 0a
:varset
vld
set /p tocopy=Location of file/folder:
set /p destination=Destination to copy to:
echo.
echo Location: %tocopy%
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 (
xcopy "%location%\*.*" "%destination%\BackupMainDir\Backup %checknum%" /s /h /e /k /f /c
pause)
It's meant to ask for a destination and location of the file to backup and the location to back up to. But I get this error? Help?
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 02 Nov 2012 00:21
You are including the destination folder in the part that is being backed up. No can do.
That's when you get a cyclic copy error.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#3
Post
by foxidrive » 02 Nov 2012 00:22
The flaw in your code looks to be that %location% is not set anywhere.
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 02 Nov 2012 14:12
%source% is usually a good variable name to use.
I am sure you will see your variable name mistake once you read your batch file.