There are several issues with this code. First, batch files require specific syntax with IF / ELSE IF .
Something like that
IF EXIST "%1" ( echo "it here!" ) ELSE ( echo "it isn't here!" )
works correctly and something like this
IF EXIST "%1" ( echo "it here!" ) ELSE ( echo "it isn't here!" )
not. A bracket restricts a block, so your IF command will execute everything between ( and ) if it evaluates to true.
Secondly, you really don't need any ELSE statements. Because you use GOTO commands immediately before your ELSE commands, you will never reach the second GOTO command if the first IF is true.
Finally, with the code you are currently showing, the tag :TOP that you have is not needed.
After all this, you should leave something similar to this:
@ECHO off IF EXIST "%1" ( GOTO COMMAND ) GOTO ERROR1 :COMMAND echo "You entered a file correctly, and it exists!" GOTO END :ERROR1 IF "%1"=="" ( GOTO ERROR2 ) GOTO ERROR3 :ERROR2 ECHO. ECHO No file(s) provided. Please re run the batch file. GOTO END :ERROR3 ECHO. ECHO The file was not found. Please re run the batch file. GOTO END :END
Nate mara
source share