First post, by pandarsson
Is choice the only dosbox command that returns an errorlevel? I was trying to make a move.bat, but in order to safely delete the old file, I need copy to give me an errorlevel. If the copy is successful, I need a 0, while if it's not, I need a 1. Here is the contents of the batch file:
@echo off
if ()==(%1) goto ERRORA
if exist %1 goto MOVE
echo The file "%1" does not exist.
goto END
:MOVE
if ()==(%2) goto ERRORB
copy %1 %2
if errorlevel 0 goto DEL
goto ERRORC
:DEL
del %1
goto END
:ERRORA
echo You must specify which file to move.
goto END
:ERRORB
echo You must specify a location.
goto END
:ERRORC
echo Unable to complete command.
:END
The offending if statement is under :MOVE. Am I doing something wrong? Am I expecting too much? Is there another way of which I haven't thought?
Yes, I know I could do other things for a move command, but I like figuring out batch files. Sue me. I suppose if nothing else, I can use the bat2com utility posted somewhere on the net and convert it in dosemu, but I wanted to check here first.