@echo off
for /f "tokens=* delims= " %%f in (myfile) do (
set line=%%f
call :processToken
)
goto :eof
:processToken
for /f "tokens=1* delims=/" %%a in (%line%) do (
echo Got one token: %%a
set line=%%b
)
if not "%line%" == "" goto :processToken
goto :eof
在我的文本文件中,我有像
这样的行"test a","test b","testdim"
"Line 2", "test d","testdin"
因此,当我看到for /f "tokens=1* delims=/" %%a in (%line%) do (
启用了ECHO时,%line%显示为"test a" "test b" "testdim"
。
我不知道为什么逗号丢失,但我需要这些逗号,以便我可以使用"delims=,"
从每行中获取这些值。
答案 0 :(得分:2)
试试这个,加上一些双引号:
@echo off &SETLOCAL
for /f "tokens=* delims= " %%f in (file) do (
set "line=%%f"
call :processToken
)
goto :eof
:processToken
ECHO "%line%"
for /f "tokens=1* delims=/" %%a in ("%line%") do (
echo Got one token: "%%a"
set "line=%%b"
)
if not "%line%" == "" goto :processToken
goto :eof
答案 1 :(得分:0)
@echo off
for /f "tokens=* delims= " %%f in (myfile) do (
set line=%%f
call :processToken
)
goto :eof
:processToken
for %%a in (%line%) do (
echo Got one token: %%a
)
goto :eof