Something rather odd happening with the parentheses for this code:
Setlocal EnableDelayedExpansion
MyFOLDER=
FOR %%B IN (c,d,e,f,g) DO (@%%B: 2>nul && set z=%%B <nul if exist %z%\
(if %MYFOLDER%==[] (echo %z%
)
)
)
The above compiles, but this doesn't:
Setlocal EnableDelayedExpansion
MyFOLDER=
FOR %%B IN (c,d,e,f,g) DO (@%%B: 2>nul && set z=%%B <nul if exist %z%\
(if %MYFOLDER%==[] (
echo %z%
)
)
)
Nor this
Setlocal EnableDelayedExpansion
MyFOLDER=
FOR %%B IN (c,d,e,f,g) DO (@%%B: 2>nul && set z=%%B <nul if exist %z%\
(if %MYFOLDER%==[]
(
echo %z%
)
)
)
nor any other combination where "echo %z%" is below the (if MYFOLDER) line. Is there anything in the "FOR" line that is suspect?
This is an updated version of the above codeblock with a description of what is intended. I think it is better to post this as a solution rather than clog up the OP or edit it any further.
The script is supposed to search all NTFS drive candidates for "common\MYFOLDER". If the first occurrence of "common\MYFOLDER" on a drive is located, do stuff with it, and continue the search for the same on other drives. The user is warned of this and can back out to :ENDSCRIPT if desired. The assembler still aborts in a cmd window at "if exist %%B:" with "%%B is unexpected at this time"
Edit: Still bombs out still at the first for I think. How is the error viewed? Is it true that if copied to existing cmd window all the nested "!!"s must be replaced with "!"
Edit2: We get "'else' is not recognized as a internal or external command..." Might it be a problem with the GOTOs?
Edit3: ") else (" is required.