if exist !SOMEPATH! not working in batch file
Posted
by
akash
on Server Fault
See other posts from Server Fault
or by akash
Published on 2014-06-11T02:34:48Z
Indexed on
2014/06/11
3:28 UTC
Read the original article
Hit count: 240
batch
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
© Server Fault or respective owner