I just got an issue which could be related to "setlocal enabledelayedexpansion"
Please correct me if I am wrong...
I have the following code:
Code: Select all
@ECHO OFF
if exist C:\auto_pkg_build\Tools\PACKAGER\extract_scheme.log (del C:\auto_pkg_build\Tools\PACKAGER\extract_scheme.log)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata1.txt (set [0] = ldata_1.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata2.txt (set [1] = ldata_2.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata3.txt (set [2] = ldata_3.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata4.txt (set [3] = ldata_4.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata5.txt (set [4] = ldata_5.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata6.txt (set [5] = ldata_6.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata7.txt (set [6] = ldata_7.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata8.txt (set [7] = ldata_8.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata9.txt (set [8] = ldata_9.txt)
if exist C:\auto_pkg_build\Scripts\scheme_replace\pkg_data\temp\fdata10.txt (set [9] = ldata_10.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 1
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\Scripts\scheme_maintenance\gen_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_maintenance\sl_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_maintenance\fk_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_maintenance\merge_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Tools\PACKAGER\md_S3S_extract.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_replace\move_schemes.cmd
timeout /t 1
C:\auto_pkg_build\Scripts\scheme_maintenance\remove_embedded_char.cmd
timeout /t 1
C:\auto_pkg_build\Scripts\scheme_maintenance\remove_embedded_duplicate.cmd
timeout /t 1
cd C:\auto_pkg_build\scripts
)
timeout /t 1
cd C:\auto_pkg_build\scripts
C:\auto_pkg_build\Scripts\scheme_maintenance\remove_embedded_char.cmd
timeout /t 1
C:\auto_pkg_build\Scripts\scheme_maintenance\remove_embedded_duplicate.cmd
timeout /t 1
Both these two scripts having "setlocal enabledelayedexpansion", not sure if it is the cause or not
Now when I run the above script. the first loop is fine but the second loop afterward, it also echo on the script as this:
C:\auto_pkg_build\Scripts>(
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 1
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\Scripts\scheme_maintenance\gen_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_maintenance\sl_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_maintenance\fk_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_maintenance\merge_sch_list.cmd
timeout /t 1
call C:\auto_pkg_build\Tools\PACKAGER\md_S3S_extract.cmd
timeout /t 1
call C:\auto_pkg_build\Scripts\scheme_replace\move_schemes.cmd
timeout /t 1
C:\auto_pkg_build\Scripts\scheme_maintenance\remove_embedded_char.cmd
timeout /t 1
C:\auto_pkg_build\Scripts\scheme_maintenance\remove_embedded_duplicate.cmd
timeout /t 1
cd C:\auto_pkg_build\scripts
)
I wonder if it is related to the "setlocal enabledelayedexpansion" in the last scripts. Although it is no harm to run the scripts but why it echo on all these scripts in the screen...???, which did not happen before I added these last two scripts...