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

I am trying to get the user to type in what they want to copy (in DOS), then copy it to the location they wish to copy, through a Batch File in DOS.

Please take a look at my code here:
http://www.triangleeventpros.com/DOS/bat.html

(Please only the latest version of DOS, NOT the old commands for older versions)


My main problem is:

I am having the most trouble around this part of the code... it's like it's not reading it right...
WHAT do I do.
I need it to validate if the File or Drive exists or not.
HELP.


Example)

IF not exist %1 echo File does not exist
goto END

IF not exist %2 echo Location does not exist
goto END

2006-06-28 10:01:41 · 2 answers · asked by Am 4 in Computers & Internet Other - Computers

The "else" statement did not work in DOS ...

2006-06-28 12:56:21 · update #1

Your way didn't work, but the same Q I had posted in a different area this dude answered it, so no sweat... but thanks!

See:

The old dude “N2FC” was right (not tryin’ to diss your age)…
I mean at first it didn’t work
But then when I told it to GOTO instead of just “not exist” stuff
Then after I moved it around (the %2==%2) then it worked…

Check it out pplZ!

http://www.triangleeventpros.com/DOS/batworking.html

THANK U!!!!!!!!!!!!!!!!!!
(Too bad I already turned it in before I got it working LOL, but at least now I know what I was doin’ wrong Hehehehe)

2006-06-28 13:16:52 · update #2

2 answers

Even though you have this resolved in another question, here are some notes for you to look at, n This is 10 lines (5 pairs of 2 lines each), make sure to put them into notepad and get rid of any line wraps before running or it might not work correctly.
========================

@echo off
cls

echo The syntax of this program is:
echo copyit a:.\dir1\dir2\filename.ext c:\.\filename.ext & echo.

if "%1"=="" echo You forgot to type the filename. & echo. & GOTO :EOF
if "%2"=="" echo You forgot to type your destination path. & echo. & GOTO :EOF

if not exist %1 echo Sorry! The file '%1' does not exist. & GOTO :EOF
if not exist %2 echo Sorry! The destination '%2' does not exist. & GOTO :EOF

echo You are copying '%1' to '%2' & echo. & copy %1 %2 >nul
if not errorlevel 1 echo The file '%1' has been copied successfully to '%2' & echo.

2006-06-28 13:46:41 · answer #1 · answered by Kevin 7 · 32 2

ur program should look like this:

@echo off

IF not exist %1 echo File does not exist
goto END
else
goto COPYTO

IF not exist %2 echo Location does not exist
goto END
else
goto COPYTO

:NOFILE

echo You forgot to type the file name
echo you wish to copy!
echo Please type the file name or path
echo you wish to copy...

echo.

echo To copy a file please type
echo the path of the file you wish
echo to copy, next type in the path
echo you wish to copy that file to.
echo.
echo It should look like this:
echo.
echo copyit A:.\dir1\dir2\filename.extention C:.\filename.extention

goto END





:NODIR

echo You forgot to type the location
echo you wish to copy the file to!
echo Please type the location you wish
echo to copy the file to...

echo.

echo To copy a file to a location
echo please type the path of the file
echo you wish to copy, next type in the path
echo you wish to copy that file to (which is
echo the location you will send the copy to).
echo.
echo It should look like this:
echo.
echo copyit A:.\dir1\dir2\filename.extention C:.\filename.extention

goto END








:COPYTO

echo You are copying %1 to %2
echo.
copy %1 %2
echo.
echo The source %1 has been copied sugcessfully!

goto END











:END

echo.
echo.

echo Press any key to return to the DOS prompt...
pause>nul

echo.
echo.

: ~END~

2006-06-28 10:20:13 · answer #2 · answered by chakradhar 1 · 0 0

fedest.com, questions and answers