The difference of using asterisk between delims = and tokens = in batch processing

Time:2021-4-14

Compare the execution results of the following two pieces of code:
1、
@echo off
for /f “delims=” %%i in (test.txt) do echo /%%i/
pause
2、
@echo off
for /f “tokens=*” %%i in (test.txt) do echo /%%i/
pause

test.txt The content of ABC is: ABC. There are several spaces at the beginning of the line.
See the difference?

Reason: “delims =” means to cancel the default separator, so the content on the line will be copied, while “tokens = *” means to get all the content on the line, but all the spaces at the beginning of the line will be ignored.