@ECHO OFF
REM RMTSTA.BAT
REM Automated file/directory rename, move, delete baseline for MARS NWE.
REM
REM Uses DOS commands over the NetWare redirector:
REM   MD, REN, MOVE, COPY, DEL, RD
REM
REM Notes:
REM   - File rename uses REN.
REM   - Directory rename uses MOVE, because this client rejects REN on dirs.
REM   - Some DOS/Novell messages may still appear on screen even when
REM     stdout is redirected. Result files are in F:\RCMP.
REM
REM Results:
REM   F:\RCMP\RUN.LOG
REM   F:\RCMP\SUMMARY.TXT
REM   F:\RCMP\PRE\*.OUT
REM   F:\RCMP\POST\*.OUT
REM   F:\RCMP\CMP\*.OUT

F:
CD \

REM --- Clean generated test/result directories (contents only). ---
IF EXIST RMTTEST\NUL DELTREE /Y RMTTEST\*.*
IF EXIST RMTCMP\NUL DELTREE /Y RMTCMP\*.*

REM --- Directory setup ---
IF NOT EXIST TRMOVE\NUL MD TRMOVE
IF NOT EXIST TRMOVE\SRC\NUL MD TRMOVE\SRC
IF NOT EXIST TRMOVE\SRC\SUB\NUL MD TRMOVE\SRC\SUB
IF NOT EXIST TRMOVE\DST\NUL MD TRMOVE\DST
IF NOT EXIST TRMOVE\DFILE\NUL MD TRMOVE\DFILE
IF NOT EXIST TRMOVE\NEMPTY\NUL MD TRMOVE\NEMPTY
IF NOT EXIST RCMP\NUL MD RCMP
IF NOT EXIST RCMP\PRE\NUL MD RCMP\PRE
IF NOT EXIST RCMP\POST\NUL MD RCMP\POST
IF NOT EXIST RCMP\CMP\NUL MD RCMP\CMP

REM --- Clean result files ---
IF EXIST F:\RCMP\RUN.LOG DEL F:\RCMP\RUN.LOG
IF EXIST F:\RCMP\SUMMARY.TXT DEL F:\RCMP\SUMMARY.TXT
IF EXIST F:\RCMP\ZIP.LOG DEL F:\RCMP\ZIP.LOG
IF EXIST F:\RCMP\RMTSTA.ZIP DEL F:\RCMP\RMTSTA.ZIP

IF EXIST F:\RCMP\PRE\ROOT.OUT DEL F:\RCMP\PRE\ROOT.OUT
IF EXIST F:\RCMP\PRE\SRC.OUT DEL F:\RCMP\PRE\SRC.OUT
IF EXIST F:\RCMP\PRE\SUB.OUT DEL F:\RCMP\PRE\SUB.OUT
IF EXIST F:\RCMP\PRE\DST.OUT DEL F:\RCMP\PRE\DST.OUT
IF EXIST F:\RCMP\PRE\DFILE.OUT DEL F:\RCMP\PRE\DFILE.OUT
IF EXIST F:\RCMP\PRE\DATES.OUT DEL F:\RCMP\PRE\DATES.OUT
IF EXIST F:\RCMP\POST\ROOT.OUT DEL F:\RCMP\POST\ROOT.OUT
IF EXIST F:\RCMP\POST\SRC.OUT DEL F:\RCMP\POST\SRC.OUT
IF EXIST F:\RCMP\POST\SUB.OUT DEL F:\RCMP\POST\SUB.OUT
IF EXIST F:\RCMP\POST\DST.OUT DEL F:\RCMP\POST\DST.OUT
IF EXIST F:\RCMP\POST\DFILE.OUT DEL F:\RCMP\POST\DFILE.OUT
IF EXIST F:\RCMP\POST\NEMPTY.OUT DEL F:\RCMP\POST\NEMPTY.OUT
IF EXIST F:\RCMP\POST\DATES.OUT DEL F:\RCMP\POST\DATES.OUT
IF EXIST F:\RCMP\POST\A2.OUT DEL F:\RCMP\POST\A2.OUT
IF EXIST F:\RCMP\POST\MOVEDB.OUT DEL F:\RCMP\POST\MOVEDB.OUT
IF EXIST F:\RCMP\CMP\ROOT.OUT DEL F:\RCMP\CMP\ROOT.OUT
IF EXIST F:\RCMP\CMP\SRC.OUT DEL F:\RCMP\CMP\SRC.OUT
IF EXIST F:\RCMP\CMP\SUB.OUT DEL F:\RCMP\CMP\SUB.OUT
IF EXIST F:\RCMP\CMP\DST.OUT DEL F:\RCMP\CMP\DST.OUT
IF EXIST F:\RCMP\CMP\DFILE.OUT DEL F:\RCMP\CMP\DFILE.OUT
IF EXIST F:\RCMP\CMP\DATES.OUT DEL F:\RCMP\CMP\DATES.OUT

ECHO RMTSTA automated rename/move/delete test > F:\RCMP\RUN.LOG
ECHO Date/time stamp skipped to avoid DOS prompt. >> F:\RCMP\RUN.LOG
ECHO. >> F:\RCMP\RUN.LOG

ECHO === RESET TEST TREE === >> F:\RCMP\RUN.LOG

REM Delete old files individually if present.
IF EXIST F:\TRMOVE\SRC\A.TXT DEL F:\TRMOVE\SRC\A.TXT
IF EXIST F:\TRMOVE\SRC\A2.TXT DEL F:\TRMOVE\SRC\A2.TXT
IF EXIST F:\TRMOVE\SRC\EXIST.TXT DEL F:\TRMOVE\SRC\EXIST.TXT
IF EXIST F:\TRMOVE\SRC\SUB\B.TXT DEL F:\TRMOVE\SRC\SUB\B.TXT
IF EXIST F:\TRMOVE\DST\B.TXT DEL F:\TRMOVE\DST\B.TXT
IF EXIST F:\TRMOVE\DST\C.TXT DEL F:\TRMOVE\DST\C.TXT
IF EXIST F:\TRMOVE\DST\DELME.TXT DEL F:\TRMOVE\DST\DELME.TXT
IF EXIST F:\TRMOVE\DFILE\A.TXT DEL F:\TRMOVE\DFILE\A.TXT
IF EXIST F:\TRMOVE\DFILE\B.TXT DEL F:\TRMOVE\DFILE\B.TXT
IF EXIST F:\TRMOVE\DFILE\KEEP.TXT DEL F:\TRMOVE\DFILE\KEEP.TXT
IF EXIST F:\TRMOVE\DMOVE\A.TXT DEL F:\TRMOVE\DMOVE\A.TXT
IF EXIST F:\TRMOVE\DMOVE\B.TXT DEL F:\TRMOVE\DMOVE\B.TXT
IF EXIST F:\TRMOVE\DMOVE\KEEP.TXT DEL F:\TRMOVE\DMOVE\KEEP.TXT
IF EXIST F:\TRMOVE\NEMPTY\KEEP.TXT DEL F:\TRMOVE\NEMPTY\KEEP.TXT
IF EXIST F:\TRMOVE\EMPTY\NUL RD F:\TRMOVE\EMPTY
IF EXIST F:\TRMOVE\DMOVE\NUL RD F:\TRMOVE\DMOVE
IF EXIST F:\TRMOVE\DFILE\NUL RD F:\TRMOVE\DFILE

REM Recreate expected directories.
IF NOT EXIST F:\TRMOVE\SRC\NUL MD F:\TRMOVE\SRC
IF NOT EXIST F:\TRMOVE\SRC\SUB\NUL MD F:\TRMOVE\SRC\SUB
IF NOT EXIST F:\TRMOVE\DST\NUL MD F:\TRMOVE\DST
IF NOT EXIST F:\TRMOVE\DFILE\NUL MD F:\TRMOVE\DFILE
IF NOT EXIST F:\TRMOVE\NEMPTY\NUL MD F:\TRMOVE\NEMPTY
IF NOT EXIST F:\TRMOVE\EMPTY\NUL MD F:\TRMOVE\EMPTY

ECHO FILE A > F:\TRMOVE\SRC\A.TXT
ECHO EXIST TARGET > F:\TRMOVE\SRC\EXIST.TXT
ECHO FILE B > F:\TRMOVE\SRC\SUB\B.TXT
ECHO FILE C > F:\TRMOVE\DST\C.TXT
ECHO DELETE ME > F:\TRMOVE\DST\DELME.TXT
ECHO DIR A > F:\TRMOVE\DFILE\A.TXT
ECHO DIR B > F:\TRMOVE\DFILE\B.TXT
ECHO DIR KEEP > F:\TRMOVE\DFILE\KEEP.TXT
ECHO KEEP > F:\TRMOVE\NEMPTY\KEEP.TXT

NPUBLIC\FLAG F:\TRMOVE\SRC\A.TXT N >> F:\RCMP\RUN.LOG
NPUBLIC\FLAG F:\TRMOVE\SRC\SUB\B.TXT N >> F:\RCMP\RUN.LOG
NPUBLIC\FLAG F:\TRMOVE\DST\C.TXT N >> F:\RCMP\RUN.LOG
NPUBLIC\FLAG F:\TRMOVE\DST\DELME.TXT N >> F:\RCMP\RUN.LOG
NPUBLIC\FLAG F:\TRMOVE\DFILE\A.TXT N >> F:\RCMP\RUN.LOG
NPUBLIC\FLAG F:\TRMOVE\DFILE\B.TXT N >> F:\RCMP\RUN.LOG
NPUBLIC\FLAG F:\TRMOVE\DFILE\KEEP.TXT N >> F:\RCMP\RUN.LOG

ECHO === PRE CAPTURE === >> F:\RCMP\RUN.LOG
NPUBLIC\NDIR F:\TRMOVE > F:\RCMP\PRE\ROOT.OUT
NPUBLIC\NDIR F:\TRMOVE\SRC > F:\RCMP\PRE\SRC.OUT
NPUBLIC\NDIR F:\TRMOVE\SRC\SUB > F:\RCMP\PRE\SUB.OUT
NPUBLIC\NDIR F:\TRMOVE\DST > F:\RCMP\PRE\DST.OUT
NPUBLIC\NDIR F:\TRMOVE\DFILE > F:\RCMP\PRE\DFILE.OUT
NPUBLIC\NDIR F:\TRMOVE /DATES > F:\RCMP\PRE\DATES.OUT

ECHO === TEST 01: rename file in same directory === >> F:\RCMP\RUN.LOG
REN F:\TRMOVE\SRC\A.TXT A2.TXT >> F:\RCMP\RUN.LOG

ECHO === TEST 02: expected failure rename to existing target === >> F:\RCMP\RUN.LOG
REN F:\TRMOVE\SRC\A2.TXT EXIST.TXT >> F:\RCMP\RUN.LOG

ECHO === TEST 03: move-like file operation via COPY+DEL across directories === >> F:\RCMP\RUN.LOG
COPY F:\TRMOVE\SRC\SUB\B.TXT F:\TRMOVE\DST\B.TXT >> F:\RCMP\RUN.LOG
DEL F:\TRMOVE\SRC\SUB\B.TXT >> F:\RCMP\RUN.LOG

ECHO === TEST 04: directory rename via MOVE === >> F:\RCMP\RUN.LOG
MOVE F:\TRMOVE\DFILE F:\TRMOVE\DMOVE >> F:\RCMP\RUN.LOG

ECHO === TEST 05: delete file === >> F:\RCMP\RUN.LOG
DEL F:\TRMOVE\DST\DELME.TXT >> F:\RCMP\RUN.LOG

ECHO === TEST 06: remove empty directory === >> F:\RCMP\RUN.LOG
RD F:\TRMOVE\EMPTY >> F:\RCMP\RUN.LOG

ECHO === TEST 07: expected failure remove non-empty directory === >> F:\RCMP\RUN.LOG
RD F:\TRMOVE\NEMPTY >> F:\RCMP\RUN.LOG

ECHO === POST CAPTURE === >> F:\RCMP\RUN.LOG
NPUBLIC\NDIR F:\TRMOVE > F:\RCMP\POST\ROOT.OUT
NPUBLIC\NDIR F:\TRMOVE\SRC > F:\RCMP\POST\SRC.OUT
NPUBLIC\NDIR F:\TRMOVE\SRC\SUB > F:\RCMP\POST\SUB.OUT
NPUBLIC\NDIR F:\TRMOVE\DST > F:\RCMP\POST\DST.OUT
NPUBLIC\NDIR F:\TRMOVE\DMOVE > F:\RCMP\POST\DFILE.OUT
NPUBLIC\NDIR F:\TRMOVE\NEMPTY > F:\RCMP\POST\NEMPTY.OUT
NPUBLIC\NDIR F:\TRMOVE /DATES > F:\RCMP\POST\DATES.OUT

ECHO === COMPARE === >> F:\RCMP\RUN.LOG
FC F:\RCMP\PRE\ROOT.OUT F:\RCMP\POST\ROOT.OUT > F:\RCMP\CMP\ROOT.OUT
FC F:\RCMP\PRE\SRC.OUT F:\RCMP\POST\SRC.OUT > F:\RCMP\CMP\SRC.OUT
FC F:\RCMP\PRE\SUB.OUT F:\RCMP\POST\SUB.OUT > F:\RCMP\CMP\SUB.OUT
FC F:\RCMP\PRE\DST.OUT F:\RCMP\POST\DST.OUT > F:\RCMP\CMP\DST.OUT
FC F:\RCMP\PRE\DFILE.OUT F:\RCMP\POST\DFILE.OUT > F:\RCMP\CMP\DFILE.OUT
FC F:\RCMP\PRE\DATES.OUT F:\RCMP\POST\DATES.OUT > F:\RCMP\CMP\DATES.OUT

ECHO === DETAILED POST READBACK === >> F:\RCMP\RUN.LOG
NPUBLIC\NDIR F:\TRMOVE\SRC\A2.TXT > F:\RCMP\POST\A2.OUT
NPUBLIC\NDIR F:\TRMOVE\DST\B.TXT > F:\RCMP\POST\MOVEDB.OUT

ECHO === SUMMARY === > F:\RCMP\SUMMARY.TXT
ECHO RMTSTA automated rename/move/delete test finished. >> F:\RCMP\SUMMARY.TXT
ECHO. >> F:\RCMP\SUMMARY.TXT
ECHO Expected final state: >> F:\RCMP\SUMMARY.TXT
ECHO - SRC contains A2.TXT and EXIST.TXT. >> F:\RCMP\SUMMARY.TXT
ECHO - SRC\SUB no longer contains B.TXT. >> F:\RCMP\SUMMARY.TXT
ECHO - DST contains B.TXT and C.TXT, but not DELME.TXT. >> F:\RCMP\SUMMARY.TXT
ECHO - DFILE was renamed/moved to DMOVE via MOVE. >> F:\RCMP\SUMMARY.TXT
ECHO - EMPTY was removed. >> F:\RCMP\SUMMARY.TXT
ECHO - NEMPTY should still exist because RD non-empty should fail. >> F:\RCMP\SUMMARY.TXT
ECHO - Rename A2.TXT to EXIST.TXT is expected to fail. >> F:\RCMP\SUMMARY.TXT
ECHO. >> F:\RCMP\SUMMARY.TXT
ECHO Optional pack results with RMTZIP.BAT. >> F:\RCMP\SUMMARY.TXT

ECHO.
ECHO RMTSTA fertig.
ECHO Ergebnisse liegen in F:\RCMP
ECHO Optional: RMTZIP ausfuehren.
ECHO.
