You're just a victim for the poorly written FOR help.
What you're missing are probably these.
- Adjacent delimiter characters are treated as one token separator.
- Delimiter at start of a line is not treated as a separator.
e.g. in the line " abc def", the first token is "abc".
- The term token for the FOR command refers to the parsed data in the source
line that is to be assigned to the environment variables, not the variables.
i.e. the numbers refers to the index of the parsed data, not the variable
indexes.
- "tokens=1*" is actually "tokens=1,*". "1*" isn't treated as one and the
rest, but one then the rest. i.e. 2 separate tokens.
- The "*" token wildcard will treat any delimiter as data. So any delimiter
characters at the end of a line will be included in the variable.
- "tokens=1-2" means the first and second data are included in the variable
assignment. i.e. "1-3" is same as "1,2,3".
For example, assume we have this incomplete command line:
for /f "tokens=1,3-4,6* delimiters=." %a in ("ab.cd...ef.gh.ij.kl.mn.op")
- Token#1 is "ab" and is assigned to %a
- Token#2 is "ef" and is assigned to %b
- Token#3 is "gh" and is assigned to %c
- Token#4 is "kl" and is assigned to %d
- Token#5 is "mn.op." and is assigned to %e
So since "tokens=1,3-4,6*" is "tokens=1,3-4,6,*".
Treat it like this: (1),(3-4),(6),(*)
Then like this: (1=%a), (3=%b, 4=%c), (6=%d), (*=%e)
I hope that isn't confusing.