Page 1 of 1

is there a difference between"DELIMS=" and "Tokens=*"

Posted: 28 Dec 2021 02:37
by nnnmmm
AA=FOR /F "Tokens=*" %%V IN ('DIR') DO ECHO a
BB=FOR /F "DELIMS=" %%V IN ('DIR') DO ECHO a

CC=FOR /F "DELIMS=*&%^^&%" %%V IN ('DIR') DO ECHO a
DD=FOR /F "DELIMS=73k0s1j4" %%V IN ('DIR') DO ECHO a

i have been using BB for all my life, my logic was if you cant find the NULL string in a text file, then it gotta be the whole line, it has been working well and provenly well for me.
my logic for CC and DD was no one uses this kind of strange 73k0s1j4 delimers, so it gotta read the whole line. but CC didnt work.

i just found the meaning of AA, it means the whole line
could someone put words for BB CC DD for me? just few words would suffice. i dont understand(or remember) operators well, but i do well on the structure. now i am going to change all my working "DELIMS=" to "Tokens=*"

Re: is there a difference between"DELIMS=" and "Tokens=*"

Posted: 28 Dec 2021 05:54
by aGerman
The meaning of AA is that it uses the whole line but strips leading default delimiters (spaces and/or tabs).
The meaning of BB is that it discards the default delimiters and thus, uses the whole line.
IIRC it was jeb who found out that AA is a little faster than BB and proposed to use both "tokens=* delims=".

CC and DD are bogus, but keep in mind that "delims=ABC" means you defined 3 deliters which are A and B and C.

Steffen

Re: is there a difference between"DELIMS=" and "Tokens=*"

Posted: 28 Dec 2021 06:04
by Compo
To begin with, your assessment of AA is incorrect. AA will pass each line which does not begin with a semicolon, ignoring any leading space and horizontal tab characters, to the DO command(s).

BB, on the other hand, will pass each line which does not begin with a semicolon, to the DO command(s).

The difference between the two is therefore that leading delimiters, (spaces and horizontal tabs are default delimiters), are stripped when using AA.

Re: is there a difference between"DELIMS=" and "Tokens=*"

Posted: 28 Dec 2021 06:12
by aGerman
Haha, yeah.

Code: Select all

for /f delims^=^ eol^= %%V ...
... (without the usual surrounding quotes) is a way to get around the default eol issue.

Steffen