bat批处理for循环嵌套

想实现对多层文件中的某些指定数据的处理

如下:

一级目录

 二级目录

 三级目录

 对所有lane文件夹下的所有cyc文件夹中的所有R001C002图像进行处理

可以使用父bat与子bat文件进行处理

子bat文件(test5.bat)代码如下:

@echo off
setlocal enabledelayedexpansion
SET Obj_Length=13
SET index=0
for %%b in (%*) do (
    SET Obj[!index!]=%%b
    SET /a index+=1
) 
    
SET ImagePath=%Obj[9]%
SET StartCyc=%Obj[0]%
SET EndCyc=%Obj[1]%
SET startR=%Obj[2]%
SET endR=%Obj[3]%
SET startC=%Obj[4]%
SET endC=%Obj[5]%
SET imageR=%Obj[6]%
SET imageC=%Obj[7]%
SET Nthroshold=%Obj[8]%

set "Lanepath=0"
set "Temp=0"
set "TempStr=Lane"
set "iLane=0"
set "iCyc=0"
set "inputfile=0"
if not exist %ImagePath%Crosstalk_Fit md %ImagePath%Crosstalk_Fit
for /f %%a in ( 'dir /b /o:n %ImagePath%') do (
    rem echo %%a|findstr "^Lane" >nul
    set "Lanepath=%%a"
    set "Temp=!Lanepath:~-6,4!"
    if !Temp! EQU !TempStr! (
        set "iLane=!Lanepath:~-2!"
        for /L %%b in (%StartCyc%,1,%EndCyc%) do (
            for /L %%r in (%startR%,1,%endR%) do (
                for  /L %%c in (%startC%,1,%endC%) do (
                    if %%b LSS 10 ( SET "iCyc=00%%b" )
                    if %%b GEQ 10 ( SET "iCyc=0%%b" )
                    set "inputfile=%ImagePath%Lane!iLane!Cyc!iCyc!intsFile_!iCyc!.txt"
                    IntsExtraction.exe %ImagePath%Lane!iLane!Cyc!iCyc! %%r %%r %%c %%c %imageR% %imageC%
                    if %errorlevel%==0 (
                        Correction_NN_Std.exe %ImagePath%Crosstalk_FitFit_Lane!iLane!_%Nthroshold%.csv !inputfile! !iCyc! %%r %%c %Nthroshold%
                        TaskRead.exe -f !inputfile!
                        ren "result.png" "CrossFile_Lane!iLane!_Cyc!iCyc!_R%%rC%%c.png"
                        move "CrossFile_Lane!iLane!_Cyc!iCyc!_R%%rC%%c.png" %ImagePath%Crosstalk_Fit
                    )
                )    
            )
        )
    ) 
)

父bat文件代码如下:

:: call 子bat文件名 StartCyc EndCyc stsrtR endR startC endC Nthroshold 输入路径
call test5.bat 1 1 2 2 2 2 1024 1024 0.1 V:FJC202002281802_B044_20200225A_FJC_hot_Tre_CK_Tre_DTTImagefile

注:IntsExtraction.exe,Correction_NN_Std.exe,TaskRead.exe是三个用于特定图像信息处理的程序

 
原文地址:https://www.cnblogs.com/caicai2019/p/12401720.html