version = "DeArc.rexx V1.3 (3/2/95)"
parse arg SourceDir DestDir
if SourceDir = '?' then
do
options prompt 'SOURCE/A,DESTINATION: '
pull SourceDir DestDir
end
if SourceDir = '' then
do
say "[1mI need a source Dir!![0m"
say ''
say '[1;32m'version'[0m - The Arexx Lha/Lzh/Zip Batch De-Archiver'
say '[1;3;33mWritten By SlingShot/Dimentia U.K 94[0m'
say ''
say '[3;4;32mUsage:[0m'
say '        [4;33mDeArc[0m [1;32m<Source Directory>[0m [1;33m[Destination][0m'
say '        [Destination] is optional and current'
say '        directory will be used if non is provided.'
say ''
say '        NOTE: Archives must have .Lha/Lzh/Zip extensions'
say '        NOTE: LHA/UnZip must be in the current path.'
exit
end
else
if ~exists(SourceDir) then
do
say "[1mNo such directory or device![0m"
say ''
say '[1;32m'version'[0m - The Arexx Lha/Lzh/Zip Batch De-Archiver'
say '[1;3;33mWritten By SlingShot/Dimentia U.K 94[0m'
say ''
say '[3;4;32mUsage:[0m'
say '        [4;33mDeArc[0m [1;32m<Source Directory>[0m [1;33m[Destination][0m'
say '        [Destination] is optional and current'
say '        directory will be used if non is provided.'
say ''
say '        NOTE: Archives must have .Lha/Lzh/Zip extensions'
say '        NOTE: LHA/UnZip must be in the current path.'
exit
end
if right(SourceDir, 1) ~= ':' & right(SourceDir, 1) ~= '/' then
SourceDir = SourceDir || '/'
if DestDir = '' then
DestDir = pragma('D') || '/'
else
if right(DestDir, 1) ~= ':' & right(DestDir, 1) ~= '/' then
DestDir = DestDir || '/'
address command
'LIST' SourceDir 'p=(#?.lha|#?.lzh|#?.zip) quick files nohead to ram:temp'
'RESIDENT c:lha force'
If open('fh','ram:temp','r') then
Do
text = readln('fh')
text = strip(text)
call close('fh')
if text = '' then check = 0 
Else check = 1
End
Else
check = 2
If check = 2 then
Do
say 'Oh no...I cant open ram:temp, the listings file!! PROBLEM!'
exit
End
If check ~= 0 then
If open('FileHandle','ram:temp','R') then
Do until eof('FileHandle')
text = readln('FileHandle')
if right(text, 3) = 'LHA' | right(text, 3) = 'lha' | right(text, 3) = 'lzh' then
'lha e 'SourceDir || text DestDir || left(text,(length(text)-4)) || '/'
Else
if right(text, 3) = 'ZIP' | right(text, 3) = 'zip' then
'unzip 'SourceDir || text '-d' DestDir || left(text,(length(text)-4)) || '/'
End
Else
Do
say "Cant open Source file listing file - Ram:temp"
exit
End
Else
say 'No LHA/LZH/ZIP files found!'
call close('FileHandle')
'delete ram:temp quiet'
'RESIDENT lha remove'
exit
