Use double quotes in if "string" == "" () else ()
Not if string == "", or if defined var () else ()
Use double quotes in set "var=string"
At the end of each label, if you don't want the processing to proceed to the next one, use Goto: EoF
You need to use another name on the label: EOF
Cmd.exe (command interpreter) will understand: "Go To End Of File"
And stop batch commands immediately without executing any of the commands on your label: EOF
C:\Users\Shaik Izaz>Goto /?
Directs cmd.exe to a labeled line in a batch program.
GOTO label
label Specifies a text string used in the batch program as a label.
You type a label on a line by itself, beginning with a colon.
If Command Extensions are enabled GOTO changes as follows:
GOTO command now accepts a target label of :EOF which transfers control
to the end of the current batch script file. This is an easy way to
exit a batch script file without defining a label. Type CALL /? for a
description of extensions to the CALL command that make this feature
useful.
@echo off & setlocal enableextensions
set "Depot_Path=//Depoth/path/..."
set "P4CLIENT=<Workspace_name>"
set "P4PORT=<IPadress:port>"
set "P4USER=%username%"
FOR /F useback^delims^= %%i IN (`p4 opened -u "%username%" "//Depoth/path/..."`) DO set "open_files=%%~i"
echo\%open_files%
if "%open_files%" == "" (
echo\No file are in pending list && goto :execute
) else (
echo=files are in pending list, please submit them if needed or revert them
echo=%open_files%
goto %:^)
)
:execute
<Do something>
Goto :eOf
%:^)
rem :: Your :eOf commands came here
rem :: In lable %:^)
rem :: Rename the label for some readable..