How to use nested FOR loops in batch files

徘徊边缘 提交于 2019-12-06 10:49:48
setlocal enabledelayedexpansion
for %%f in (DataFolder\*.Ext) do (
    set POI=%%~f
    set POI=!JbPOI:DataFolder\=!
    set POI=!JbPOI:.Ext=!
    for /f  "useback tokens=1,2,3 delims=," %%a in ("%%~f") do (
        set CX=%%a
        set CY=%%b
        set FN=%%c
        echo !FN!,9,!CX!,!CY! >> "DataFolder\!POI!.tmp"
    )
)
endlocal

I'm not sure if you want to read the file "%%~f" , but I think this is what you need.

Sorry, but for the posted code i don't see the need for delayed expansion. All the needed data is being directly retrieved from the for replaceable parameters

setlocal enableextensions disabledelayedexpansion
for %%f in (DataFolder\*.Ext) do (
  (
    for /f  "usebackq tokens=1-3 delims=," %%a in ("%%~f") do echo(%%c,9,%%a,%%b
  ) > "DataFolder\%%~nf.tmp"
)
endlocal

If the real code includes something not posted, maybe the answer from npocmaka will better fit in the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!