Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Why does IF [!LoopMo:~0,1!] result in an error?

$
0
0

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.


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>