Pages

DOS: if exist

@echo off

REM #######################
REM # Set Object Value
REM #######################

SET filename=D:\temp\test.bat
SET RETURN_MSG=

REM #######################
REM # Check object exist
REM #######################

if exist %filename% goto FOUND
SET RETURN_MSG=MESSAGE: Object not found
goto NOTFOUDN


:FOUND
SET RETURN_MSG=MESSAGE: Object found
echo %RETURN_MSG%
goto EXITOUT

:NOTFOUDN
echo %RETURN_MSG%
goto EXITOUT


:EXITOUT

No comments:

Post a Comment

Thank you for your feedback. If you find the tip and trick useful, feel free to share with your friends on Facebook, Twitter and G+!