home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / move2lzh.lha / LZH.REX next >
Encoding:
OS/2 REXX Batch file  |  1990-02-14  |  2.6 KB  |  105 lines

  1. /*
  2.     A utility that will convert all ARCED,ZOOED ZIPPED or PAKED
  3.     files in a particular directory into LZH files for more
  4.         efficient space saving.
  5.     Also requires that ARC,ZOO, and UNZIP be in the C: or current directory. 
  6.     As much error checking has been built in as possible.
  7.                 December 29, 1989 - Basil 71361,2622
  8. */
  9.  
  10. LF='0A'x
  11. parse upper arg inputdir
  12.  
  13. If inputdir = "" then
  14.     do
  15.         say "Enter volume or directory to convert "
  16.         pull inputdir
  17.     end
  18. If ~exists(inputdir) then 
  19.     do
  20.         say "That volume or directory does not exist."
  21.         exit 10
  22.     end
  23.  
  24.     /*  make sure that inputdir is correctly ended */
  25.  
  26.   if (index(inputdir,':') == 0) then inputdir = inputdir||':'
  27.     else if (index(inputdir,':') ~= length(inputdir)) then
  28.         do 
  29.           if (index(inputdir,'/') ~= length(inputdir)) then inputdir = inputdir||'/'
  30.             end
  31.  
  32.  
  33. Files = showdir(inputdir,'F')
  34.  
  35.         /* we're only interested in files with the correct suffix ...
  36.              others are left alone */
  37.  
  38. DO FOREVER
  39.  
  40. if ~exists('ram:formatdir') then address command 'makedir ram:formatdir'
  41. Fileflag = 0
  42. Call parseout
  43. If firstfile = "" then leave
  44. select 
  45.     when Ending = '.ARC' then
  46.         do
  47.             address command 'copy 'inputdir||firstfile||' to ram:formatdir'
  48.         address command 'cd ram:formatdir'LF'arc x ' firstfile LF'delete' firstfile
  49.             fileflag = 1
  50.         end
  51.     when Ending = '.ZOO' then
  52.         do
  53.             address command 'copy 'inputdir||firstfile||' to ram:formatdir'
  54.         address command 'cd ram:formatdir'LF'zoo x ' firstfile LF'delete' firstfile
  55.             fileflag = 1
  56.         end
  57.     when Ending = '.ZIP' then
  58.         do
  59.             address command 'copy 'inputdir||firstfile||' to ram:formatdir'
  60.             address command 'cd ram:formatdir'LF'unzip 'firstfile LF
  61.             fileflag = 1
  62.         end
  63.     when Ending = '.PAK' then
  64.         do
  65.             address command 'copy 'inputdir||firstfile||' to ram:formatdir'
  66.             address command 'cd ram:formatdir'LF firstfile LF'delete' firstfile
  67.             fileflag = 1
  68.         end
  69.     otherwise
  70. end
  71.  
  72. If fileflag = 1 then
  73.     do
  74.         newfile = left(firstfile,(length(firstfile)-4))||'.LZH'
  75.         contents = showdir('ram:formatdir','F')
  76.         address command 'cd ram:formatdir'LF'lharc a '||newfile||' *'LF
  77. if rc ~= 0 then exit
  78.         address command 'delete 'inputdir||firstfile LF
  79.         address command 'copy ram:formatdir/'||newfile||' to 'inputdir LF
  80.         address command 'delete ram:formatdir all' LF
  81.     end
  82.  
  83.  
  84. END
  85.  
  86.   /* ********************* END OF MAIN PROGRAM ********************* */
  87.  
  88. parseout:
  89.  
  90.         /* recursive parsing routine that pulls out and uses the
  91.              first file of the list.  */
  92.  
  93.     parse var Files firstfile Files 
  94.  
  95.         /* let's extract the suffix */
  96.  
  97. if firstfile ~= "" then
  98.     do
  99.         Dotposition = length(firstfile)-3
  100.         Ending = substr(firstfile,Dotposition,4)
  101.     end
  102.  
  103. return
  104.  
  105.