if exist !SOMEPATH! not working in batch file
- by akash
I have a batch script in which i am using multiple if exist statement, the problem is all statements are working except one .
Following variables are set
SETLOCAL ENABLEDELAYEDEXPANSION
SET basedrive=E:
SET tfworkspace=!basedrive!\TFS
SET envdefault=%1
SET projenv=!envdefault!
echo subapp=!subapp! subappservice=!subappservice!
SET tfworkspacepath=!tfworkspace!\!releasebranch!\!app!\!subapp!
SET tfworkspacepathservice=!tfworkspace!\!releasebranch!\!app!\!subapp!\sourcecode\build\!projenv!
This statement works,
if exist "!tfworkspacepath!" (robocopy "!tfworkspacepath!"\sourcecode\messagebroker\ /E /NFL /NJS /NDL /ETA "!basedir!\!messagebroker!" ) else SET /a foldererror=1
This statement doesn't work, by does not work i mean even thou the path does not exist it it still tries to robocopy.
if exist !tfworkspacepathservice! (
robocopy !tfworkspacepathservice! /E /NFL /NJS /NDL /ETA "!basedir!\!scripts!") else SET /a foldererror =!foldererror!+1
I am new to batch writing, please guide me