In the following script IF [!LoopMo:~0,1!] gives an error while IF [%LoopMo:~0,1%] does not.
I understand that I do not need the ! and that in this case the % will do but I would like to understand it?
Thanks.
echo off
SETLOCAL EnableDelayedExpansion
SET LoopDate=01/20/2014
set loopM=5642626
SET LoopMo=%LoopDate:~0,2%
echo %loopM%
echo %loopMo%
IF [!LoopMo:~0,1!] == [0] ( SET LoopM=!LoopMo:~1,1!
) ELSE ( SET LoopM=!LoopMo!
)
echo %loopM%
echo %loopMo%
The error I get is:
5642626
01
1!] was unexpected at this time.