home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 31
/
CDASC_31_1996_juillet_aout.iso
/
vrac
/
fact127.zip
/
4AR.BTM
next >
Wrap
Text File
|
1996-05-23
|
10KB
|
451 lines
::*────────────────────────────────────────────────────────────────────────┐
::* Simple 4DOS Archive Reader. Allows you to read files within archives. │
::* Public Domain, by David Daniel Anderson. Version 1.27, 23-May-1996 │
::* Comments welcome: dda@panasia.com │
::* │
::* Run with just a question mark (?) to view basic help and information. │
::* │
::* Note: Go to line number 33 to set your preferred file viewer. │
::*────────────────────────────────────────────────────────────────────────┘
iff "%1"=="" then
if exist *.* goto startbtm
if "%@findfirst[*.*,d]" ne "" goto startbtm
else
if "%1"=="?" goto help
if exist %1 goto startbtm
if isdir %1 goto startbtm
if "%@findfirst[%1,d]" ne "" goto startbtm
endiff
::! If run in a totally empty directory, or
::! if run with an invalid first parameter, then show help.
goto help
::! NOTE: I unset my PROMPT and CDPATH in large BTM's to release some
::! precious environment space. Do NOT unset COMSPEC or PATH!
:startbtm
setlocal
unalias *
set prompt=
set cdpath=
::! Change the following to whatever program you use to read files.
set read=LIST
iff %_env lt 300 then
cls
echo.
echo WARNING!
echo.
echo This batch file consumes 150 to 300 bytes of environment space.
echo You only have %_env bytes of environment space available now.
echo.
echo OPTION 1: Press "c" if you want to continue anyway.
echo.
echo OPTION 2: Press "r" to recurse (have the batch file call itself
echo with a larger environment). It will do this by calling another
echo instance of: %comspec
echo.
echo OPTION 3: Press any other key to terminate the batch file.
echo Note: If you choose this option, you can edit lines 24+ of the
echo batch file to unset any unneeded variables.
echo.
inkey %%y
iff %@upper["%y"]=="C" then
set y=
goto continue
endiff
iff %@upper["%y"]=="R" then
set y=
%comspec //EnvFree=350 /c %0 %&
else
echo Quitting at your request.
quit
endiff
quit
endiff
::! Set unique temporary subdirectory name, and create it.
:continue
set tempdir=%@search[%@unique[%temp]]
if "%tempdir"=="" goto error1
del /q %tempdir
md %tempdir
attrib /dq +h %tempdir
::! Set files to select.
iff "%1"=="" then
set arcf=%_cwds%*.*
cdd %tempdir
else
set newarc=%@full[%1]
cdd %tempdir
::! If %1 refers to a directory, then use it.
iff NOT isdir %newarc then
::! If %1 refers to one file, then immediately act on that one.
iff %@findfirst[%newarc]=%newarc then
::! Set the primary file selection to all files in the same dir as %1
set arcf=%@path[%newarc]*.*
goto CheckExt
endiff
::! Else preserve the ambiguous parameter.
endiff
set arcf=%newarc
endiff
::! Select an archive to process.
::! Pressing "Escape" will allow us to exit.
:SelArc
cls
set newarc=
*select /e /o:en set newarc=(%arcf)
if %newarc.==. goto cleanup
::! Reset archive selection menu.
:ReSetArc
iff isdir %newarc then
set arcf=%@full[%newarc]
goto SelArc
endiff
::! Check whether this file is an archive.
::! If it is, then set the necessary compressor parameters.
::! If not, then just view it.
:CheckExt
iff islabel %@ext[%@word[0,%newarc]] then
*unset /q aview aextr left width fs c l
gosub %@ext[%@word[0,%newarc]]
else
%read %@word[0,%newarc]
goto Backout
endiff
::! Select a file to extract.
set xfile=
cls
%aview %@word[0,%newarc] %c | set xfile=%@select[con,0,0,%_rows,%_columns,┤ Select a file: ├]
cls
::! If we pressed "Escape", back up one level.
if "%xfile"=="" goto Backout
::! Get an actual file name to extract.
set xfile=%@trim[%@substr[%xfile,%left,%width]]
if "%xfile"=="" goto Backout
::! Change forward slashes to backward slashes.
:BSlash
set fs=%@index[%xfile,/]
iff %fs ge 0 then
set xfile=%@substr[%xfile,0,%fs]\%@substr[%xfile,%@eval[%fs+ 1],255]
goto BSlash
endiff
::! Convert double spaces to single.
:OneSpace
set fs=%@index[%xfile, ]
iff %fs ge 0 then
set xfile=%@substr[%xfile,0,%fs]%@substr[%xfile,%@eval[%fs+ 1],255]
goto OneSpace
endiff
::! Convert space-dot to just dot.
:SpaceDot
set fs=%@index[%xfile, .]
iff %fs ge 0 then
set xfile=%@substr[%xfile,0,%fs]%@substr[%xfile,%@eval[%fs+ 1],255]
goto SpaceDot
endiff
::! Replace the first remaining space with a period.
:Periods
set fs=%@index[%xfile, ]
iff %fs ge 0 then
set xfile=%@substr[%xfile,0,%fs].%@substr[%xfile,%@eval[%fs+ 1],255]
REM goto Periods
endiff
::! Now extract the file, if it doesn't exist.
cls
iff "%all"=="y" then
if not exist %xfile %aextr %@word[0,%newarc] %l
unset /q all
else
if not exist %xfile %aextr %@word[0,%newarc] %xfile %l
endiff
if %? ge 1 (beep^pause)
*unset /q aview aextr left width fs c l
cls
::! Append new name to string of files being searched.
set newarc=%_cwds%%xfile %newarc
iff %_env lt 100 then
cls
echo.
echo You are running low on environment space!
echo If you go deeper into this archive, you may run into problems.
echo Environment left: %_env
echo.
set
echo.
pause
endiff
set xfile=
::! Finally, go back to determine if this is an archive or not.
goto CheckExt
::! Back out of nested searching.
:Backout
set newarc=%@trim[%@substr[%newarc,%@eval[%@len[%@word[0,%newarc]]],255]]
iff "%newarc"=="" then
::! Make sure we are in the temp dir, and erase everything
::! before starting a new archive.
cdd %tempdir
del /sxyz /q *.* >&>nul
goto SelArc
else
goto CheckExt
endiff
::! Sent here to remove temporary directory when we are done.
:cleanup
cdd %tempdir
cd ..\
iff isdir %tempdir then
del /sxyz /q %tempdir >&>nul
endiff
quit
:error1
echo Your TEMP variable is set to a location which either does not exist
echo or is a READ-ONLY drive. You must fix it before running this batch
echo file.
echo.
pause
goto help
::!##########################################################################
::!
::! The rest of the .BTM consists of definitions for various compressors.
::! Here is how to define them:
::!
::! :??? Create a label with the compressor's file extension.
::!
::! aview= The command to view the archive contents.
::! aextr= The command to extract a file from the archive.
::! left= The number of characters from the beginning of the
::! internal file names to the *left* edge of the screen.
::! width= The maximum width that the filenames may take up (usually 12).
::! return Since these are "gosubs", you MUST end with "return".
::!
::! Note: not all of these definitions handle subdirectories properly.
::!
::!##########################################################################
:acb
set aview=acb l
set aextr=acb r
set left=33
set width=40
set all=y
return
:ain
set aview=ain l
set aextr=ain e
set left=0
set width=12
return
:arc
set aview=pkunpak -v
set aextr=pkunpak -e
set left=0
set width=12
return
:arj
set aview=arj l
set aextr=arj e
set left=0
set width=12
return
:dwc
set aview=dwc v
set aextr=dwc e
set left=0
set width=12
return
:ha
set aview=ha l
set aextr=ha e
set left=2
set width=12
return
:hap
set aview=hap l
set aextr=pah e
set c=*.*
set left=11
set width=12
return
:hpk
set aview=hpack v -r
set aextr=hpack x -r -dc
set left=47
set width=12
return
:hyp
set aview=hyper -v
set aextr=hyper -xo -p
set left=49
set width=29
return
:jrc
set aview=jrcl
set aextr=jrce
set left=0
set width=12
return
:lib
set aview=codec -v
set aextr=codec -d
set c=* -m -q
set l=-m
set left=0
set width=33
return
:lim
set aview=limit l
set aextr=limit e
set left=2
set width=12
return
:lzh
set aview=lha v
set aextr=lha x
set left=0
set width=64
return
:lzs
set aview=larc l
set aextr=larc e /x /o
set left=0
set width=64
return
:pak
set aview=pak v
set aextr=pak e
set left=0
set width=12
return
:paq
set aview=unpaq -v
set aextr=unpaq -x -d
set left=29
set width=50
set all=y
return
:rar
set aview=rar v -std -bw
set aextr=rar x -std -bw
set left=1
set width=40
return
:sar
set aview=sar l
set aextr=sar e
set left=0
set width=12
return
:sqz
set aview=sqz l
set aextr=sqz e
set left=2
set width=12
return
:uc2
set aview=uc vs
set aextr=uc esf
set left=0
set width=12
return
:x
set aview=x1 l
set aextr=x1 xy
set left=0
set width=21
return
:yc
set aview=yac l
set aextr=yac e
set left=41
set width=12
return
:zip
set aview=pkzip -vb
set aextr=pkunzip -d
set left=46
set width=29
return
:zoo
set aview=zoo -list
set aextr=zoo -extract
set left=49
set width=12
return
:help
echo.
echo 4DOS batch file: %0
echo Public Domain, by David Daniel Anderson. Version 1.27, 23-May-1996
echo.
echo Usage: %0 [archive(s)]
echo.
TEXT
This 4DOS batch file allows you to read files within archives.
In order to use this, you will need the archivers themselves,
and a file viewer (or use 4DOS's LIST command -- see line #33).
This batch file comes preconfigured for the archivers that use
the following extensions:
ACB AIN ARC ARJ DWC HA HAP HPK HYP JRC
LIB LIM LZH LZS PAK PAQ RAR SAR SQZ UC2
X YC ZIP ZOO
Adding more definitions, and editing these, are both simple tasks.
See the comments in the batch file, starting at line number 234.
Note: not all archivers are 100% compatible with the methods I use.
ENDTEXT
quit