I've tried
for /F "delims= " %%A in ("Hello World") do echo %%A %%B
and it says
Hello
%B
I need to get %%A and %%B to be 'hello' and 'world' but what I've tried above doesn't work. What do I need to do? I've tried without "delims= " and without /F and it's still not working.
答案 0 :(得分:2)
you need also tokens
option:
for /F "tokens=1,2 delims= " %%A in ("Hello World") do echo %%A %%B
and 1
will become %%A
and the second token corresponds to %%B
.In this case the out put will be "Hello Earth":
for /F "tokens=1,2,3 delims= " %%A in ("Hello planet Earth") do echo %%A %%C
答案 1 :(得分:1)
you forgot to specify the tokens (Default is "tokens=1", so %%b
is not valid with your code):
for /f "tokens=1,2 delims= " %%a in ("hello world") do echo %%a-%%b
the shorter version without /f
is:
for %%i in (hello world) do echo %%i