home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
opus
/
v4
/
dopbt41
/
4
/
rexx
/
repack1.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1995-04-18
|
3KB
|
96 lines
/* LHA-LZX V1.0 by Mat Bettinson of the Plot Hatching Factory '95
Minor bug fix by niels
Since Jonathan Forbes' brilliant LZX came along and promptly blew LHA away,
there's a need for a bulk converter. This is such a device.
Simply executing the script with the Directory to convert will result
in each and every single LHA or LZH file in that dir being converted to LZX.
You'll need LHA and LZX in your path and the Delete command.
It also needs a fat temp dir as large as the largest uncompressed archive
to work and this is the first thing in the script so you can alter at will.
Below is the two only real values you must change. One is the Temp Dir where
all LHA files will be extracted to. There must be enough room in this drawer
for the largest of archives to unpack to so I DO NOT recommend RAM: unless you
have a great DEAL of RAM. Beware! LZX eats memory too. The other parameter is
the compression mode. It can be 1,2 or 3 varying from fastest & Lowest CR to
Slowest & Highest CR. Even mode 1 is better than LHA.
New for 2.0:
Priority setting in header below.
By default, will not replace LHA archives if larger using LZX.
Above can be disabled so that ALL files are replaced as per original Repack by
using the 'FORCELZX' switch after the Dir name.
Filenotes are copied.
*/
TempDir = 'dh2:t/'
Mode = '3'
Priority = -1
/*************************************************/
/* I recommend you leave it alone from here. :-) */
/*************************************************/
Arg Dir Force
say
say ' *** LZX-LHA repacker 2.0 by Mat Bettinson of the Plot Hatching Factory ***'
If Dir = '' then signal Usage
If ~EXISTS(Dir) then signal Usage
If Force ~= '' & Force ~= 'FORCELHA' then signal Usage
If Force = 'FORCELHA' then ForceLHA = 1
ELSE ForceLHA = 0
say
Call Pragma('S',50000)
If right(Dir,1) ~= '/' & right(Dir,1) ~= ':' then Dir = Dir'/'
Address COMMAND 'Assign REPACK: 'Tempdir
Call Pragma('D','REPACK:')
Address COMMAND 'List 'Dir' PAT #?.LZX FILES LFORMAT "%n %c" >t:LZX-LHA.temp'
Call Open(list,'t:LZX-LHA.temp','R')
BSave = 0
DO forever
Line = ReadLN(list)
File = strip(word(line,1)) ; Comment = strip(word(line,2)) ; Comment = Strip(Comment,'B','"')
IF EOF(list) then break
NewFile = Left(File,Length(file)-3)'LHA'
say 'Converting file: 'File
Address COMMAND 'Delete >NIL: REPACK:#? ALL FORCE'
Call Open(ts,Dir||file) ; Lhasize = Seek(ts,0,'E') ; Call Close(ts)
Address COMMAND 'LZX -a -M X -F' Dir||File' #? REPACK:'
Address COMMAND 'lha -erlb128D2MY -F a 'Dir||NewFile' REPACK:#?'
Call Open(ts,Dir||NewFile) ; Lzxsize = Seek(ts,0,'E') ; Call Close(ts)
Diff = Lhasize - Lzxsize
If Diff > 0 | ForceLHA then DO
Address COMMAND 'Delete >NIL: 'Dir||File
If Comment ~= '' then Address COMMAND 'Filenote 'DIR||NewFile' "'Comment'"'
say '* 'Diff' bytes saved on this archive!' ; say
END
ELSE DO
Address COMMAND 'Delete >NIL: 'Dir||Newfile
say '* LHA file 'ABS(Diff)' bytes larger than LZX. Keeping LZX...' ; say
Diff = 0
END
BSave = BSave + Diff
END
Call Close(list)
Address COMMAND 'delete repack:#? all force >nil:'
Address COMMAND 'Assign REPACK: REMOVE'
Address COMMAND 'delete t:LZX-LHA.temp all force >nil:'
say
say ' *** LHA-LZX Repacker 2.0 finished. 'Bsave' bytes saved in this dir. ***'
say
EXIT
Usage:
say
say 'Usage: [rx] Repack <Directory> [FORCELHA]'
say
EXIT