delims values specify the character or characters that will be used to "split" a string into tokens. A delimiter is only one byte, but more than one delimiter may be specified for multiple surgeries. tokens values specify which of the tokens to put into the "for"-loop variables. Examples: for /f "delims=* tokens=1,3" %%a in ("this*is*test") splits "this*is*test" into three tokens, based on location of delimiter *, but the tokens says only get the first and third, and ignore the second. Tokens assignment to for-loop variables begins with the variable named (in this case, %%a), and successive active, or called-for tokens are assigned in alphabetical order. Since only two tokens are being activated, in this example, the vars. to receive the values will be %%a and %%b. Note that since token #2 is ignored, it does not occupy a variable. To be sporting, I will let you guess the final result. There are a number of other considerations, such as how null tokens are handled (they are ignored). For /f "delims=* tokens=1,3-4" %%a in ("****first token***x* **fourth") gives only tokens with non-null values (a space is not a null, it will be assigned.) The best thing to do is experiment, using the dbl-quoted string syntax (the form that I used in examples), and see what happens when you change the string and the key-parameter specifications.
|