@ECHO OFF
REM (ZZZZZZCPTR.BAT) TEST TO REAL DATA COPY OR DIRREM 1=iv 2=sys_lang 3={TEST,REAL} 4=system 5=job 6={DIR,COPY} 7=msg_file 8=copy_file
IF "%5"=="" EXIT /B
SET I_EXIT=%SYSTEMDRIVE%\I\I.%4\TMP_%3\%5.EXIT
ECHO ??? START ZZZZZZCPTR.BAT > %I_EXIT%
SET TMP=%SYSTEMDRIVE%\I\I.%4\TMP_%3
IF "%6"=="DIR" GOTO DIR
IF "%6"=="COPY" GOTO COPY
ECHO %6 ERROR > %I_EXIT%
EXIT /B
:DIR
dir /L \I\I.%4\DATA_TEST\*.* | SORT > %TMP%\%7_TEST.TXT
dir /L \I\I.%4\DATA_REAL\*.* | SORT > %TMP%\%7_REAL.TXT
goto FIN
:COPY
IF "%8"=="" EXIT /B
IF "%3"=="TEST" EXIT /B
IF EXIST \I\I.%4\DATA_OLD9_REAL\%8 DEL  \I\I.%4\DATA_OLD9_REAL\%8  
IF EXIST \I\I.%4\DATA_OLD8_REAL\%8 MOVE \I\I.%4\DATA_OLD8_REAL\%8 \I\I.%4\DATA_OLD9_REAL\%8 
IF EXIST \I\I.%4\DATA_OLD7_REAL\%8 MOVE \I\I.%4\DATA_OLD7_REAL\%8 \I\I.%4\DATA_OLD8_REAL\%8 
IF EXIST \I\I.%4\DATA_OLD6_REAL\%8 MOVE \I\I.%4\DATA_OLD6_REAL\%8 \I\I.%4\DATA_OLD7_REAL\%8 
IF EXIST \I\I.%4\DATA_OLD5_REAL\%8 MOVE \I\I.%4\DATA_OLD5_REAL\%8 \I\I.%4\DATA_OLD6_REAL\%8 
IF EXIST \I\I.%4\DATA_OLD4_REAL\%8 MOVE \I\I.%4\DATA_OLD4_REAL\%8 \I\I.%4\DATA_OLD5_REAL\%8 
IF EXIST \I\I.%4\DATA_OLD3_REAL\%8 MOVE \I\I.%4\DATA_OLD3_REAL\%8 \I\I.%4\DATA_OLD4_REAL\%8 
IF EXIST \I\I.%4\DATA_OLD2_REAL\%8 MOVE \I\I.%4\DATA_OLD2_REAL\%8 \I\I.%4\DATA_OLD3_REAL\%8 
IF EXIST \I\I.%4\DATA_OLD1_REAL\%8 MOVE \I\I.%4\DATA_OLD1_REAL\%8 \I\I.%4\DATA_OLD2_REAL\%8
IF EXIST \I\I.%4\DATA_REAL\%8 COPY \I\I.%4\DATA_REAL\%8 \I\I.%4\DATA_OLD1_REAL\%8 2>%I_EXIT%
IF ERRORLEVEL 1 EXIT /B
copy \I\I.%4\DATA_TEST\%8 \I\I.%4\DATA_%3\%8 2>%I_EXIT%
IF ERRORLEVEL 1 EXIT /B
:FIN
ECHO !!! > %I_EXIT%
