Computing.Net > Forums > Programming > how to check batch file

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

how to check batch file

Reply to Message Icon

Original Message
Name: JimWoodrow
Date: August 11, 2002 at 14:01:57 Pacific
Subject: how to check batch file
Comment:

I am just begining to learn about batch files and am starting out very easy. Is there any way to run a check on a batch file to show where you went wrong in the programing. I am working on a batch file to back up a few simple files to a secondary hard drive. After runing the file, I get an error..."invalid parameter" ................
NAMA OF BATCH FILE "Backup To D Drive"
@echo off
cls
echo Copying Files...
echo.
xcopy /e/s "c:\Jim" d:\backup\Jim /y/q
xcopy /e/s "c:\Brenda" d:\backup\Brenda /y/q
xcopy /q "c:\Program Files\Outlook Express" d:\backup\Outlook Express /y/q
echo.
echo Files are now backed up.
echo.
echo Press Enter Key.
goto end
:end

The first two "Xcopy" lines" run properly. The third "Xcopy" line is where the problem is. Hope you can help.I would still like to know how to check for errors automatically if possible. Many thanks. JimW


Report Offensive Message For Removal


Response Number 1
Name: john
Date: August 11, 2002 at 14:33:24 Pacific
Reply: (edit)

maybe it is because you used more then the old 8.3 standard try this

xcopy /q "c:\progra~1\Outloo~1"
I am not sure if I got the 8.3 name correct for outlook express if your using widows 98 goto dos mode and see what it says for outlook express for the 8.3 standard

John


Report Offensive Follow Up For Removal

Response Number 2
Name: JimW
Date: August 11, 2002 at 20:02:55 Pacific
Reply: (edit)

John,
The "old 8.3 standard" works except, every time I run the following file.....,

@echo off
rem Clears the screen
cls
rem Writes to the screen
echo Copying Files...
echo.
rem XCOPY /e/s = sub dirs /y=respond yes to all /q=quiet mode
rem xcopy "source" "destination"
xcopy /e/s "C:\Progra~1\Outloo~1\EMailF~1" D:\BackUp\Outloo~1 /y/q
rem More screen writing
echo.
echo Files are now backed up.
echo.
rem Waits for a keystroke at end
pause

It says, "file not found" and then, "files copied" What is missing or even added in the one and only "xcopy" string that I am not seeing?????? Thanks..JimW


Report Offensive Follow Up For Removal

Response Number 3
Name: Jeff J
Date: August 11, 2002 at 20:19:47 Pacific
Reply: (edit)

You don't have to use 8.3; in the original you simply forgot to put quotes around the destination. Without quotes, long filenames are parsed using whitespace as separators (worst thing ever added to long filename support). Thus, the third xcopy arguments look like:

source="c:\Program Files\Outlook Express"
destination=d:\backup\Outlook
unkownArgument=Express

along with the switches. The string 'Express' is invalid to a DOS command.

I often just use the old-school method of debugging scripts: log often. That is, echo at critical steps (you can remove them later), leave out quiet switches until things have been verified, and so on. If you temporarily turn off your quiet switches, you might find your problem. Debugging is a pain, but often necessary.

Cheers


Report Offensive Follow Up For Removal

Response Number 4
Name: NULL
Date: August 11, 2002 at 20:33:15 Pacific
Reply: (edit)

May be this will help:

***********************************************************************************
rem batch file for backing up files
@echo off
cls
echo Copying Files...
echo.

xcopy /e/s "c:\Jim" d:\backup\Jim /y/q > nul
if errorlevel 4 goto param1
if errorlevel 1 goto file1
echo Copy success
goto next1

:param1
echo error: invalid parameter
goto next1

:file1
echo error: file not found

:next1
xcopy /e/s "c:\Brenda" d:\backup\Brenda /y/q > nul
if errorlevel 4 goto param2
if errorlevel 1 goto file2
echo Copy success
goto next2

:param2
echo error: invalid parameter
goto next2

:file2
echo error: file not found

:next2
xcopy /q "c:\Program Files\Outlook Express" "d:\backup\Outlook Express" /y/q > nul
if errorlevel 4 goto param3
if errorlevel 1 goto file3
echo Copy success
goto next3

:param3
echo error: invalid parameter
goto next3

:file3
echo error: file not found

:next3
echo.

echo Files are now backed up.
echo.
pause
***********************************************************************************


Report Offensive Follow Up For Removal

Response Number 5
Name: JimW
Date: August 12, 2002 at 06:02:20 Pacific
Reply: (edit)

Thanks for the great help and time involved in your answers. Much appreciated. This will give me something to work at and a logical path to follow as well.

JimW


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 6 Days.
Discuss in The Lounge
Poll History




Data Recovery Software