test.txt:
http://www.test.com|test.rar|test
@echo off
FOR /F "eol=; tokens=1,2,3* delims=|" %%i in (test.txt) do @echo %%i %%j %%k
pause
exit
终于知道这个for /f分割与变量设置值!
delims 分割标志
tokens 以分割标志设置变量须序取值 *代表剩下全部内容
为了更好的了解变成这个你就明白了!
FOR /F "eol=; tokens=1,2,3 delims=|" %%a in (test.txt) do @echo %%a %%b %%c
现在就是有一个问题,就是 %%a,%%b,%%c如何设置一个全局变量了?
url = %%a
file = %%b
dir = %%c
以上设置了应该全局变量,当跳到for循环时只要%url%,%file%,%dir%就可以得到相关的值!
来一个完整例子吧!
FOR /F "eol=; tokens=1,2,3 delims=|" %%a in (test.txt) do (
url = %%a
file = %%b
dir = %%c
goto downing
)
:downing
wget %url%/%file% -O .\%dir%\
要得到如果就是这样:
wget
http://www.test.com/test.rar -O .\test\
就是不知道for中全局变量如何设置的?