home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Utilities
/
arc2arc
/
arc2arc.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
2000-08-16
|
2KB
|
124 lines
/*
** $VER: arc2arc.rexx 2.5 (16.8.00) Rolf Max Rotvel
*/
/*
** Configuration
*/
/* Number of dearchivers */
dearc.0 = 7
/* Dearchivers */
dearc.1 = '.TAR.GZ cc:untar020 KEEP' /* Childpatterns before parentpatterns */
dearc.2 = '.GZ cc:gzip -d -c >' /* GZip requires redirection */
dearc.3 = '.LZX cc:unlzx -x'
dearc.4 = '.ZIP cc:unzip'
dearc.5 = '.LZH lha x'
dearc.6 = '.TGZ cc:untar020 KEEP'
dearc.7 = '.LHA lha x'
/* Number of archivers */
arc.0 = 3
/* Archivers */
arc.1 = 'LHA lha a' /* Default archiver */
arc.2 = 'LZX cc:lzx040 -bi128 -bo128 -e -F -M4000 -Qf -r -9 a'
arc.3 = 'ZIP cc:zip -R -9'
/* Tmpdir */
tmpdir = 't:' /* Where to unpack archives */
/*
** End of configuration
*/
call addlib('rexxsupport.library', 0, -30, 0)
address command
file = arg(1)
if file = '?' then do
say 'Usage: <arctype> filename'
exit
end
arc = ''
arctype = upper(word(file, 1))
do i = 1 to arc.0
if arctype = word(arc.i, 1) then do
arc = subword(arc.i, 2)
leave
end
end
if arc = '' then do
if exists(file) then do
arctype = word(arc.1, 1)
arc = subword(arc.1, 2)
end
else do
say 'No archiver found for "'arctype'"'
say 'or "'file'" doesn''t exist'
exit
end
end
else file = subword(file, 2)
cmd = ''
do i = 1 to dearc.0
pat = upper(word(dearc.i, 1))
patlen = length(pat)
cuthere = (length(file) - patlen)
if pos(pat, upper(file)) = cuthere + 1 then do
cmd = subword(dearc.i, 2)
leave
end
end
if cmd = '' then do
say 'No dearchiver found for "'file'"'
exit
end
newfile = substr(file, 1, cuthere)
tmpdir = makepath(tmpdir, 'arc2arc_tmp')
olddir = pragma('d', tmpdir)
if olddir = '' then do
if ~makedir(tmpdir) then exit 10
call pragma('d', tmpdir)
end
/* For unpacking to STDOUT (GZip) */
if right(cmd, 1) = '>' then do
cmd = cmd||makepath(tmpdir, getfilepart(substr(file, 1, lastpos('.', file)-1)))
end
desc = subword(statef(file), 8)
desc = strip(translate(desc, "'", '"'))
cmd file
arc newfile '#?'
/* ! */
if desc ~= '' then 'filenote 'newfile'.'arctype' "'desc'" QUIET'
'delete 'makepath(tmpdir, '#?')' ALL FORCE QUIET'
exit
GETFILEPART: procedure
parse arg path
return strip(substr(path, max(pos(':', path), lastpos('/', path)) + 1))
MAKEPATH: procedure
parse arg path, file
if pos(right(path, 1), ':/') = 0 then return path'/'file
return path||file