0
@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 ON 时,%line% 显示为"test a" "test b" "testdim".

我不知道为什么缺少逗号,但我需要这些逗号以便我可以使用"delims=,"这些值从每一行中获取。

4

2 回答 2

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
于 2013-06-17T06:08:44.683 回答
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
于 2013-06-17T14:12:29.237 回答