Double %
are sometimes used (eventhough I do not know the exact purpose; I think it is for a delayed expansion though) but in your case it is just the connection of two variables used:
set foo=foo
set bar=bar
echo %foo%%bar%
-> foobar
Another use of it (at least in batch files) is the declaration and usage of variables in for loops: for /l %%I in(1,1,5) do echo %%i
. In the command prompt you would only write %i
.
The second line you posted makes no sense to me to be honest... Thanks to Aacinis comment this makes sense to me now! What basically gets done is:
Variables are set
with an /A
rithmetic term where a 1
is added in front to subtract it back again. Example:
set /a year=1%YYYY%-10000
-> Set the value of the variable year to the value of the variable 1YYYY - 10000. This is done (thanks to Aacini for the explanation again) to prevent the input with a leading zero (e.g. 08) to get interpreted as an octal value which in this case would lead to an invalid date. Notice that there is a difference if you use /a
or not:
set foo=1+1
set /a bar=1+1
echo foo %foo%
echo bar %bar%
Next we have another case of %%
which in this case is the modulo operator.
The modulo operator will return the rest of a division if you will. Examples:
10 %% 2 = 0 (You can divide 10 by 2 without any rest)
11 %% 4 = 3 (as 8 by 4 is 2 and the rest from 8 to 11 is 3)
I the variable leap is saved whether the year is a leap year (value == 0) or not (value != 0). However this is somewhat taken easy with the other rules you have to think of when checking for leap years but that does not belong here...
%startDate:~2,1%%startDate:~5,1%
Will produce a string that takes the 1 character after the first 2 and the 1 after the first 5 characters. In your case you would have to change that to ~4,1
and ~7,1
as the 5th and 8th character are the dashes the program checkes for.
J.Baoby suggested this link to have a closer look to. Two other great sources for help about are Dostips and SS64.
Feel free to ask questions :)