Due to my limit, I had following cases which made the code as hard coded instead of open for variations.
The logic is the following
1) pre-conditions: based upon the reading of a file (one script), I got some data output as data!n!.txt as below:
data1.txt
data2.txt
data3.txt
data4.txt (in this case 4, but may be more than 4 or less than 4)
2) I need to process these above data files to be used for the following script which is only for the first data1.txt processing, and I made 4 scripts similar to this one to be able to process data2.txt, data3.txt and data4.txt
Code: Select all
@echo off
cd C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp
if exist echo_data_1.txt (del echo_data_1.txt)
if exist echo_sch_1.txt (del echo_sch_1.txt)
for /f "tokens=1-9 delims=," %%A in (data1.txt) do call :EachLine %%A %%B %%C %%D %%E %%F %%G %%H %%I
:EachLine
set a=%1
set b=%3
set c=%4
set c=%c:"=%
set d=%5
set e=%6
set f=%7
ECHO %d% >>echo_data_1.txt
ECHO %b% >>echo_data_1.txt
ECHO %c% >>echo_sch_1.txt
if %a% NEQ 0 (ECHO %1 >>echo_data_1.txt)
if %e% NEQ 0 (ECHO %6 >>echo_data_1.txt)
if %f% NEQ 0 (ECHO %7 >>echo_data_1.txt)
4) Now I would like these data files to be used in the below code
Code: Select all
@ECHO OFF
set [0] = data_1.txt
set [1] = data_2.txt
set [2] = data_3.txt
set [3] = data_4.txt
for /F "tokens=2 delims==" %%n in ('set [') do (
cd C:\auto_pkg_build\Scripts\scheme_replace
del pkg_data.txt
cd C:\auto_pkg_build\Scripts\scheme_replace\pkg_data
copy %%n C:\auto_pkg_build\Scripts\scheme_replace
timeout /t 2
cd C:\auto_pkg_build\Scripts\scheme_replace
ren %%n pkg_data.txt
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_replace\get_variable.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_replace\pre_sch_extract.cmd
timeout /t 1
call C:\auto_pkg_build\Tools\PACKAGER\list_comp_sch.cmd
timeout /t 1
call C:\auto_pkg_build\Tools\PACKAGER\md_S3S_extract.cmd
timeout /t 1
cd C:\auto_pkg_build\Tools\PACKAGER
)
So the above code can accommodate any number variations of the data files...
I wish I could use only one scripts to do this job but due to the data processing is sort of complex....
Thanks