home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / applications / wp / xes131.lha / XES / REXX / MultiFiles.xdme < prev    next >
Encoding:
Text File  |  1994-12-23  |  4.6 KB  |  150 lines

  1. /* MultiFiles.dme: Uses the ReqTools File Requester to delete, crunch,
  2.    decrunch, copy, move, print, or load multiple files */
  3. /* Copyright © 1994 Fergus Duniho */
  4.  
  5. parse arg com .
  6.  
  7. select
  8.     when com = "ViewArc" then do
  9.         hailstr = "Select Archives to View"
  10.         oktext = "_View"
  11.     end
  12.     when com = "Unarchive" then do
  13.         hailstr = "Select Archives to Extract"
  14.         oktext = "_Extract"
  15.     end
  16.     otherwise do
  17.         hailstr = "Select Files to" com
  18.         oktext = "_" || com
  19.     end
  20. end
  21. tagstr = "rt_reqpos=reqpos_centerscr rtfi_flags=freqf_multiselect|freqf_patgad"
  22. if com = "Delete" then tagstr = tagstr || "|freqf_selectdirs|freqf_save"
  23. if com = "Load" then tagstr = tagstr "rtfi_matchpat=~(#?.xsrc)"
  24. address 'XDME.1'
  25. options results
  26. 'rxresult $path'
  27. P = result
  28. 'rxresult $fname'
  29. N = result
  30.  
  31. if com = "ViewArc" | com = "Unarchive" then do
  32.     P = "Misc:Archives"
  33.     N = ""
  34. end
  35.  
  36. call rtfilerequest(P,N,hailstr,oktext,tagstr,files)
  37. If files = 0 Then Exit
  38.  
  39. Select
  40.     When com = "Delete" Then Do X = 1 to files.count
  41.         Call Remove files.X
  42.     End
  43.     When com = "Unpack" Then Do X = 1 to files.count
  44.         C = 'xpack "' || files.X || '"'
  45.         Say "Unpacking" files.X "..."
  46.         Address Command C
  47.     End
  48.     When com = "Copy" | com = "Move" Then Do
  49.         if files.count = 1 then do
  50.             tagstr = "rt_reqpos=reqpos_centerscr rtfi_flags=freqf_patgad"
  51.             dest = rtfilerequest(P,N,"Select Destination",,tagstr)
  52.         end
  53.         else do
  54.             tagstr = "rt_reqpos=reqpos_centerscr rtfi_flags=freqf_nofiles"
  55.             dest = rtfilerequest(P,,"Select Destination",,tagstr)
  56.         end
  57.         if rtresult = 1 then do
  58.             do X = 1 to files.count
  59.                 C = com '"' || files.X || '" "' || dest || '"'
  60.                 Say C
  61.                 Address Command C
  62.             End
  63.         End
  64.     End
  65.     When com = "Print" Then Do
  66.         D = Request(22,19,"Select Destination", "PRT:", " Print ", " Cancel ")
  67.         If D ~= "" Then Do
  68.             Do X = 1 to files.count
  69.                 C = 'Type "' || files.X || '" to "' || D || '"'
  70.                 Say C
  71.                 Address Command C
  72.             End
  73.         End
  74.     End
  75.     When com = "Run" Then Do X = 1 to files.count
  76.         C = 'runback "' || files.X || '"'
  77.         Say C
  78.         Address Command C
  79.     End
  80.     When com = "Load" Then Do X = 1 to files.count
  81.             C = "newwindow chfilename (" || files.X || ") rx LoadFile"
  82.             C
  83.     End
  84.     When com = "Unarchive" Then Do
  85.         tagstr = "rt_reqpos=reqpos_centerscr rtfi_flags=freqf_nofiles|freqf_save"
  86.         dest = rtfilerequest(P,,"Select Destination",,tagstr)
  87.         if rtresult = 1 then do
  88.             do X = 1 to files.count
  89.                 tail = upper(right(files.X, 3))
  90.                 select
  91.                     when tail = "LHA" | tail = "LZH" | tail = "RUN" then
  92.                         unarc = 'tools:compression/lha -m -a x "' || files.X || '"' '"' || dest || '"'
  93.                     when tail = "ZIP" then
  94.                         unarc = 'tools:compression/unzip -o "' || files.X || '"'
  95.                     when tail = "ZOO" then
  96.                         unarc = 'tools:compression/zoo x./ "' || files.X || '"'
  97.                     otherwise iterate
  98.                 end
  99.                 Say unarc
  100.                 Address Command unarc
  101.             End
  102.         End
  103.     End
  104.     When com = "ViewArc" Then Do
  105.         Call Delete 'T:Archives'
  106.         Do X = 1 to files.count
  107.             tail = upper(right(files.X, 3))
  108.             select
  109.                 when tail = "LHA" | tail = "LZH" | tail = "RUN" then
  110.                     view = 'tools:compression/lha >>T:Archives v'
  111.                 when tail = "ZIP" then
  112.                     view = 'tools:compression/unzip >>T:Archives -v'
  113.                 when tail = "ZOO" then
  114.                     view = 'tools:compression/zoo >>T:Archives -list'
  115.                 otherwise iterate
  116.             end
  117.             C = 'execute (' || view '"' || files.X || '")'
  118.             C
  119.         End
  120.         'execute (C:runback SYS:Utilities/Most T:Archives)'
  121.     End
  122.     Otherwise Do X = 1 to files.count
  123.         C = 'xpack "' || files.X || '" method' com
  124.         Say "Packing" files.X "with" com "compression ..."
  125.         Address Command C
  126.     End
  127. End
  128. Exit
  129.  
  130. Remove: Procedure
  131.     parse arg fname
  132.     if word(statef(fname), 1) = "DIR" then do
  133.         call filelist(Pattern(fname), files, , "E")
  134.         do x = 1 to files.0
  135.             Call Remove files.x
  136.         end
  137.     end
  138.     Say "Deleting" fname "..."
  139.     call delete fname
  140.     call delete fname || ".info"
  141. return
  142.  
  143. Pattern: Procedure
  144.     parse arg dir
  145.     if right(dir, 1) ~= ":" then
  146.         pat = dir || "/*"
  147.     else
  148.         pat = dir || "*"
  149. return pat
  150.