Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Multi line for nested in a multi line if

Given the following batch file, the "for %%f in" never enters the block using TCC LE 13.04.63 on Win 7 64 bit. An old 4NT 7.00.311 works fine.

If I removed the statement if not exist %cdciBinPath%\*.* md %cdciBinPath% it works.

/////////////////////////////////

@echo off

set binFiles=1 2
set cdciBinPath=.\temp

if not "%binFiles%"=="" (
echo xxxxxxxxxxxxxxxxxxx
if not exist %cdciBinPath%\*.* md %cdciBinPath%
for %%f in (%binFiles%) do (
echo yyyyyyyyyyyyyyyyyyyyyy
if errorlevel 1 (
set ErrorArg=%%f
goto ErrFileMissing
)
)
)
goto end

:end
 
Changing the option "Duplicate CMD.EXE bugs" in the OPTIONS dialog -- first tab, right-hand column -- might help you. But I'd recommend rewriting those multi-line IF statements using IFF/ENDIFF, which is more structured and usually a better choice for complex constructs.
 
Using TCC/LE native syntax would provide many simplifications. Under HELP -> Conditional Expressions you find condition tests such as isdir and defined.Under MD/MKDIR you will find the /Ne option, which allows attempting to create a preexisting directory without an error message (all you care about is the result, not how you got there).

BTW, judging from the absence in the quoted code of the target label of a GOTO, it is just the segment of the batch file exhibiting the problem.
 
Back
Top