@echo off REM collect all the Curve Plane files and make two files one with CMM data and other with corrected points setlocal EnableDelayedExpansion For /l %%s in (1, 1, 6) do ( set nr=4 IF %%s equ 1 set nr=5 IF %%s equ 3 set nr=5 echo s and n %%s !nr! For /l %%r in (1,1,!nr!) do ( raw_and_pnts.exe Vrt_no_wt "%%s_%%r" )) if exist Vrt_no_wt_CMM_all.txt ( del Vrt_no_wt_CMM_all.txt) if exist Vrt_no_wt_pnts_all.txt ( del Vrt_no_wt_pnts_all.txt) copy *.tmpd Vrt_no_wt_CMM_all.txt copy *.tmpp Vrt_no_wt_pnts_all.txt del *.tmpd del *.tmpp echo done!