home *** CD-ROM | disk | FTP | other *** search
- @echo off
- rem For DOS«3.3 one may change 'call' into 'command/c' or use the external CALL
- rem program (by me) and remove the '@' before the 'echo off'.
- ctty con
- for %%N in (0 1) do if "%1"==".rcx%%N" goto _RCX_%%N
- rem if "%1"==".rcx0" goto _RCX_0 ──┤
- rem if "%1"==".rcx1" goto _RCX_1 ──┘
-
- if "%1"=="" goto no_log
- if "%2"=="" goto no_log
- rem Open/append log file RCX.LOG during the first initial run only:
- echo ========================== RCX.LOG ==========================>>rcx.log
- echo.|date|find "is">>rcx.log
- echo.|time|find "is">>rcx.log
- echo COMMAND LINE: %0 %1 %2 %3 %4 %5 %6 %7 %8 %9>>rcx.log
-
- :no_log
- goto _RCX
-
- :_RCX_0
- shift
- shift
- :_RCX
- rem Change root '\' as target dir into '\.' for correct further processing
- if "%1"=="\" goto is_root
- for %%f in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do if "%1"=="%%f:\" goto is_root
- for %%f in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if "%1"=="%%f:\" goto is_root
- goto continue
-
- :is_root
- %0 .rcx0 %0 %1. %2 %3 %4 %5 %6 %7 %8 %9
- :continue
- rem ....................... process DELETE parameter ........................
- if "%1"=="" goto DelProcessed
- if "%2"=="" goto DelProcessed
-
- rem If parameter .d or .D is specified somewhere, make it the second one '.d'
- rem If it has not been specified make the second parameter '.n' of not '.nested'
- if "%2"==".n" goto DelProcessed
- for %%d in ( .D) do if "%%d"=="%2" %0 .rcx0 %0 %1 .d %3 %4 %5 %6 %7 %8 %9
- for %%d in (.d .D) do if "%%d"=="%3" %0 .rcx0 %0 %1 .d %2 %4 %5 %6 %7 %8 %9
- for %%d in (.d .D) do if "%%d"=="%4" %0 .rcx0 %0 %1 .d %2 %3 %5 %6 %7 %8 %9
- for %%d in (.d .D) do if "%%d"=="%5" %0 .rcx0 %0 %1 .d %2 %3 %4 %6 %7 %8 %9
- for %%d in (.d .D) do if "%%d"=="%6" %0 .rcx0 %0 %1 .d %2 %3 %4 %5 %7 %8 %9
- for %%d in (.d .D) do if "%%d"=="%7" %0 .rcx0 %0 %1 .d %2 %3 %4 %5 %6 %8 %9
- for %%d in (.d .D) do if "%%d"=="%8" %0 .rcx0 %0 %1 .d %2 %3 %4 %5 %6 %7 %9
- for %%d in (.d .D) do if "%%d"=="%9" %0 .rcx0 %0 %1 .d %2 %3 %4 %5 %6 %7 %8
- if not "%2"==".nested" if not "%2"==".d" %0 .rcx0 %0 %1 .n %2 %3 %4 %5 %6 %7 %8
-
- :DelProcessed
- rem Suppress initial message with nested runs (recursive loops), specified by '.nested'
- if "%2"==".nested" goto begin1
-
- echo RCX ReCursive .arc/.zipfile eXtractor by Jim Groeneveld, vs. 1.0, 29/1-93.
- echo ------------------------------------------------------------------------------
- echo Extracts one or more archives (.ARC/.ZIPfiles) into subdirectories named by
- echo the file_name part of the archive (or 'filename.DIR' if the archive has no
- echo extension itself) relative to the destination directory.
- echo ZIPfiles are extracted including their eventually stored directory structure.
- echo Nested archives (.ARC/.ZIPfiles) are recursively extracted into subdirectories
- echo named by the embedded .ARC/.ZIPfiles relative to the parent ARC/ZIPfile.
- rem (DOS 2+)
- echo.
- if "%1"=="" goto helpRCX
- if "%2"=="" goto helpRCX
- if "%1"=="?" goto helpRCX
- if "%1"=="/?" goto helpRCX
- if "%1"=="-?" goto helpRCX
- if "%1"=="/h" goto helpRCX
- if "%1"=="/H" goto helpRCX
-
- :begin1
- echo --- Check existence of target_path %1 ---
- REM 'if not exist %1\nul goto no_target' REMOVE (replaced by 11 lines below)
- if exist %1\*.* goto begin2
- rem If command above did not find anything the subdir might exist but be empty.
- rem Avoid screen output if redirection below does not succeed: CTTY NUL.
- ctty nul
- rem write dummy file to the path %1 to check its existence
- rem>%1\$0-BYTE$.NUL
- ctty con
- if not exist %1\$0-BYTE$.NUL goto no_target
- rem The drive:path %1 does not exist (anymore).
- rem Or the disk may be write protected.
- del %1\$0-BYTE$.NUL
-
- :begin2
- rem --- Process archive specifications %3 %4 %5 %6 %7 %8 %9 ---
- ctty nul
- for %%f in (%3 %4 %5 %6 %7 %8 %9) do call %0 .rcx1 %0 %1\ %2 %%f
- rem Try to add extensions .ARC and .ZIP to any file name (wildcard) if not nested:
- if "%2"==".nested" goto nested
- if exist %3.arc for %%f in (%3.ARC) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %4.arc for %%f in (%4.ARC) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %5.arc for %%f in (%5.ARC) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %6.arc for %%f in (%6.ARC) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %7.arc for %%f in (%7.ARC) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %8.arc for %%f in (%8.ARC) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %9.arc for %%f in (%9.ARC) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %3.zip for %%f in (%3.zip) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %4.zip for %%f in (%4.zip) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %5.zip for %%f in (%5.zip) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %6.zip for %%f in (%6.zip) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %7.zip for %%f in (%7.zip) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %8.zip for %%f in (%8.zip) do call %0 .rcx1 %0 %1\ %2 %%f
- if exist %9.zip for %%f in (%9.zip) do call %0 .rcx1 %0 %1\ %2 %%f
-
- :nested
- ctty con
- if "%2"==".nested" goto endRCX
- rem Final termination of program, report here
- echo === RCX terminated normally; see log file RCX.LOG ===
- echo.>>rcx.log
- goto endRCX
-
- :no_target
- echo --- Trying to create target_path %1 ---
- md %1
- REM 'if exist %1\nul goto begin2' REMOVE (replaced by about 10 lines below)
- rem Avoid screen output if redirection below does not succeed: CTTY NUL.
- ctty nul
- rem write dummy file to the path %1 to check its existence
- rem>%1\$0-BYTE$.NUL
- ctty con
- if exist %1\$0-BYTE$.NUL goto Delete_1
- echo *** Target path %1 does not exist and cannot be created. ABORT.
- echo *** Target path %1 does not exist and cannot be created. ABORT.>>rcx.log
- goto nested
-
- :Delete_1
- rem Delete dummy check file
- del %1\$0-BYTE$.NUL
- goto begin2
-
- :helpRCX
- echo Syntax: RCX «target_path» «source_path_file» [«source_path_file» [..]] [.d]
- echo in which
- echo «target_path» = [d:]path of destination (drive/)directory, or relative
- echo to current ('.') one, excl. trailing '\'!
- REM -------- (REDUNDANT) --------- Specify root '\' eventually as '\.'.
- echo «source_path_file» = [d:][path\]filename of ARC/ZIPfile(s) to extract (up to 7)
- echo (wildcards allowed; extensions redundant)
- echo Avoid files with the same file name part and
- echo different archive ext's (.ARC and .ZIP).
- echo .d = parameter indicating deletion of original archive
- echo (.ARC/.ZIP) after extraction.
- echo Embedded ARC/ZIPfiles always are automatically deleted.
- :endRCX
- goto exit
-
- :_RCX_1
- shift
- shift
- rem _RCX_1 receives (1) target_path, (2) deletion option (.d or .n or .nested)
- rem and (3) single file specification
- rem If parameter (4) exists it is the already discriminated filename part
- rem If parameter (5) exists it is the already discriminated extension or 'none'
- rem In fact %3 is never expected to be empty, but though:
- if "%3"=="" goto endRCX_1
- REM *** for %%f in (.d .D .nested .d.arc .D.arc .d.zip .D.zip) do if "%2"=="%%f" goto endRCX_1
- rem %3 may not exist if a single file name (no wildcard) was specified
- if not "%4"=="" goto make_sub
- if not exist %3 goto not_exist
- rem create subdirectory from single file specification:
- rem Uility GETFNX discriminates a.o. the filename
- echo --- Search for filename part in %3 ---
- call GETFNX %3
- if not exist GETFNX2.BAT goto nogetfnx
- GETFNX2 %0 .rcx1 %0 %1 %2 %3
- rem -------------- loopback
-
- :nogetfnx
- echo *** Directory name can not be determined. Leave archive in place.
- rem (or some other solution: issuing standard directory names)
- goto exit
-
- :make_sub
- rem If no extension was specified with the source file make the subdirectory name,
- rem in which to extract, equal to the file name and the extension 'DIR' and
- rem add a dot after the original file name in order to avoid PKUNPAK and PKUNZIP
- rem to assume their implicit extension .ARC or .ZIP:
- if "%5"=="none" %0 .rcx1 %0 %1 %2 %3. %4.DIR NONE
- rem Second loop: delete scratch file GETFNX2.BAT, used in first loop
- if exist GETFNX2.BAT del GETFNX2.BAT
- rem make subdirectory (and test for success); first test for existence
- REM 'if exist %1%4\nul goto extract' REMOVE (replaced by 14 lines below)
- if exist %1%4\*.* goto extract
- rem If command above did not find anything the subdir might exist but be empty.
- rem Avoid screen output if redirection below does not succeed: CTTY NUL.
- ctty nul
- rem write dummy file to the path %1%4 to check its existence
- rem>%1%4\$0-BYTE$.NUL
- ctty con
- if exist %1%4\$0-BYTE$.NUL goto Delete_2
- rem The drive:path %1%4 does not exist.
- goto create
-
- :Delete_2
- rem Delete dummy check file
- del %1%4\$0-BYTE$.NUL
- goto extract
-
- :create
- echo --- Trying to create subdirectory %1%4 ---
- md %1%4
- REM 'if exist %1%4\nul goto extract' REMOVE (replaced by 14 lines below)
- if exist %1%4\*.* goto extract
- rem If command above did not find anything the subdir might exist but be empty.
- rem Avoid screen output if redirection below does not succeed: CTTY NUL.
- ctty nul
- rem write dummy file to the path %1%4 to check its existence
- rem>%1%4\$0-BYTE$.NUL
- ctty con
- if exist %1%4\$0-BYTE$.NUL goto Delete_2
- rem The drive:path %1%4 does not exist.
- echo *** Subdirectory %1%4 could not be created, archive %3 not extracted and deleted.
- echo *** Subdirectory %1%4 could not be created, archive %3 not extracted and deleted.>>rcx.log
- goto endRCX_1
-
- :not_exist
- echo *** File %3 does not exist, no action.
- echo *** File %3 does not exist, no action.>>rcx.log
- goto endRCX_1
-
- :extract
- echo --- Extract archive %3 into subdirectory %1%4 ---
- for %%a in (arc ARC) do if "%5"=="%%a" goto arc_direct
- rem Avoid files with the same file name part and different archive ext's (.ARC and .ZIP).
- pkunzip -d -JHSR %3 %1%4
- if not errorlevel 1 goto del_archive
-
- :arc_direct
- pkunpak -x %3 %1%4
- if not errorlevel 1 goto del_archive
- rem Errorlevel is at least 1
- echo *** An error occurred while extracting archive %3, not deleted!
- echo *** An error occurred while extracting archive %3, not deleted!>>rcx.log
- goto restart
-
- :del_archive
- echo !!! Archive %3 extracted successfully>>rcx.log
- if "%2"==".n" goto restart
- rem else %2 is either '.d' or '.nested' indicating deletion
- echo Auto-deletion of %3
- del %3
- if exist %3 goto not_deleted
- echo !!! Archive %3 deleted>>rcx.log
- goto restart
-
- :not_deleted
- echo *** Archive %3 could not be deleted automatically.
- echo *** Archive %3 could not be deleted automatically.>>rcx.log
-
- :restart
- rem Restart RCX specifying target_SUBdirectory as both (relative) target and source recursively
- echo --- Process eventual archives (ARC/ZIPfiles) in %1%4 ---
- ctty nul
- call %0 .rcx0 %0 %1%4 .nested %1%4\*.ARC %1%4\*.ZIP
- ctty con
- :endRCX_1
- rem goto exit
-
- :exit
-