@ECHO OFF REM check whether a file called 'test.txt' exists IF EXIST test.txt GOTO :success IF NOT EXIST test.txt GOTO :error :success ECHO OK - file test.txt exists GOTO :end :error ECHO Error - can't find the test.txt file GOTO :end :end ECHO This is the end of the file