English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am writing a batch file that would first look into a directory and check if the files that I specify are their. If not that look in another directory and xcopy them. This is the script I have:

@echo off


REM Makes a Folder on the U: drive
MD u:\Notes

c:
if Exist set a="Program files\lotus\notes\"(


xcopy C:\%a%\notes.ini U:\Notes\ /y /e

xcopy C:\%a%\Data\*.id U:\Notes\ /y /e

xcopy C:\%a%\Data\Desktop6.ndk U:\Notes\ /y /e

xcopy C:\%a%\Data\bookmark.nsf U:\Notes\ /y /e

xcopy C:\%a%\Data\names.nsf U:\Notes\ /y /e

xcopy C:\%a%\Data\Cache.NDK U:\Notes\ /y /e

)


Else set a= AppData\Local\Lotus\Notes\" (

xcopy C:\%a%\notes.ini U:\Notes\ /y /e

xcopy C:\%a%\Data\*.id U:\Notes\ /y /e

xcopy C:\%a%\Data\Desktop6.ndk U:\Notes\ /y /e

xcopy C:\%a%\Data\bookmark.nsf U:\Notes\ /y /e

xcopy C:\%a%\Data\names.nsf U:\Notes\ /y /e

xcopy C:\%a%\Data\Cache.NDK U:\Notes\ /y /e

)

@pause

2007-07-30 06:25:09 · 3 answers · asked by Jessie S 1 in Computers & Internet Programming & Design

The problem is, it does not work. Says files is not found and that

'Else' is not recognized as an internal or external command,
operable program or batch file.

2007-07-30 06:36:01 · update #1

I am even more confused. Let me see if I am getting this.
If I were to do this:

if set a=Program files\lotus\notes goto if set a=Program files\lotus\notes (
xcopy C:\%a%\notes.ini U:\Notes\ /y /e

xcopy C:\%a%\Data\*.id U:\Notes\ /y /e

xcopy C:\%a%\Data\Desktop6.ndk U:\Notes\ /y /e

xcopy C:\%a%\Data\bookmark.nsf U:\Notes\ /y /e

xcopy C:\%a%\Data\names.nsf U:\Notes\ /y /e

xcopy C:\%a%\Data\Cache.NDK U:\Notes\ /y /e
)
echo this is the if part




REM echo this is the else part
goto after
xcopy C:\Doucment and Settings\%username%\Local Settings\Application Data\Lotus\Notes\Data\notes.ini U:\Notes\ /y /e

xcopy C:\Doucment and Settings\%username%\Local Settings\Application Data\Lotus\Notes\Data\*.id U:\Notes\ /y /e

xcopy C:\Doucment and Settings\%username%\Local Settings\Application Data\Lotus\Notes\Data\Desktop6.ndk U:\Notes\ /y /e

xcopy C:\Doucment and Settings\%username%\Local Setti

2007-07-31 02:44:57 · update #2

3 answers

You're exactly right - else is invalid:

This is how to do an if-else statement in a batch file:

if condition goto ifcondition
echo this is the else part
goto after
ifcondition:
echo this is the if part
after:
echo this is after the if-else

or

if not condition goto notcondition
echo this is the if part
goto after
notcondition:
echo this is the else part
after:
echo this is after the if-else

where condition is the condition to be checked for.

So you're absolutely right about the else.

2007-07-30 07:34:52 · answer #1 · answered by E.M.Bed 5 · 0 0

Looks OK to me. Did you try to use 'step' to move through the routine one line at a time. This will help you locate the problem, if there is one.

2007-07-30 13:35:18 · answer #2 · answered by radar 3 · 0 0

This looks ok. What's the problem?

2007-07-30 13:27:09 · answer #3 · answered by Scotty Doesnt Know 7 · 0 0

fedest.com, questions and answers