home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / arch11.zip / ArcH.CMD next >
OS/2 REXX Batch file  |  1993-06-25  |  7KB  |  153 lines

  1. /*===================================================================*/
  2. /* Archive Handler v1.1 - Sean Camanyag                              */
  3. /*   Usage: ARCH.CMD [archive name, full path required]              */
  4. /*===================================================================*/
  5. /* History: v1.0 - Initial release, based on NEWZIPS.CMD [SC]        */
  6. /*          v1.1 - Cleaned up code using filespec commands. Added    */
  7. /*                 capability to view GZip (*.gz) files by calling   */
  8. /*                 Gzip then running user-specified file lister.     */
  9. /*                 Changed documentation a little. Made better use   */
  10. /*                 of work variables (archive programs, listers)     */
  11. /*-------------------------------------------------------------------*/
  12. /*                                                                   */
  13. /* This is my first real REXX program. I wrote it because I wanted a */
  14. /* way to handle .ZIP and .LZH archives using a WPS Folder.          */
  15. /*                                                                   */
  16. /* I'm pretty much clueless when it comes to programming; most of    */
  17. /* this was done from looking at Felix Sawicki's NEWZIPS.CMD on      */
  18. /* OS/2 Shareware BBS. (NEWZIPS.ZIP)  NEWZIPS seemed intended for    */
  19. /* Sysops who examine all uploads personally.  At the time I was     */
  20. /* calling various BBS's and checking FTP sites for some utility     */
  21. /* that let the user handle .ZIPs via the WPS, as a .ZIP file was    */
  22. /* double clicked on.                                                */
  23. /*                                                                   */
  24. /* I came across a utility that did that, however it was hard-coded  */
  25. /* to use the PKWare OS/2 ZIP 1.x programs, which did not support    */
  26. /* PKZip 2.0 format archives. Also, I didn't like its interface.     */
  27. /*                                                                   */
  28. /* I really wanted something to help me get un-used to the command   */
  29. /* line, so, after about 2 hours of work, constantly looking at the  */
  30. /* online REXX documentation and NEWZIPS.CMD, I got this to work.    */
  31. /*                                                                   */
  32. /* This was intended to be associated with .ZIP,.LZH, and .gz files. */
  33. /* .gz files are those created by GZip, commonly used on FTP sites.  */
  34. /* Gzip's default extension is .gz, but will read .z files as well.  */
  35. /* You can easily add .z support by copying the .gz section, and     */
  36. /* adding appropriate changes to the "get archive type" area.        */
  37. /*                                                                   */
  38. /* Make a object for this CMD file. Then use an association editor   */
  39. /* (such as ASSOED03.ZIP) and link the ZIP/LZH/gz files so that when */
  40. /* you double-click on their icons, Archive Handler will run on it.  */
  41. /*                                                                   */
  42. /* This program is public domain; feel free to modify it in any way  */
  43. /* you want.  All I ask is that you mention that your modification   */
  44. /* acknowledges me and F. Sawicki, if you upload it somewhere.       */
  45. /* Please let me know of any fixes you make, and where I can         */
  46. /* download it.  My internet email addresses are:                    */
  47. /*                                  scamany@eis.calstate.edu         */
  48. /*                                     bgc1@delphi.com               */ 
  49. /*                                                                   */
  50. /* The documentation from NEWZIPS.CMD says that Felix Sawicki can be */
  51. /* contacted on the local msg area of OS/2 Shareware BBS.            */
  52. /*                                                                   */
  53. /* Disclaimer: (who doesnt use em, these days)                       */
  54. /*             I take no responsibility at all for any damage this   */
  55. /*             rexx program may do. It's provided as-is, no          */
  56. /*             guarantees, etc etc, even if I'm aware of such        */
  57. /*             dangers, etc etc etc etc... You get the idea.         */
  58.  
  59. /* Turn .CMD echo off */
  60. "@ECHO OFF"
  61.  
  62. /* Remind user about making an object */
  63. SAY 'You should create an object for this .CMD file.'
  64. SAY 'Put a check mark on the [Start Minimized] area in the Settings tab,'
  65. SAY 'and this window wont be visible anymore'
  66.  
  67. /* Handle Arguments */
  68. parse arg arcname
  69.  
  70. /* Set work variables - **CHANGE THIS TO YOUR NEEDS** */
  71. workdrv = 'E:'  
  72. workdir = '\Comm\Test'
  73. workpath = 'E:\Comm\Test\'
  74. unzipprg = 'unzip -o '
  75. unlzhprg = 'LH X -o '
  76. ungzprg = 'GZip -d '
  77. gzprg = 'GZip -9 '
  78. fileview = 'PMV '
  79.  
  80. /* Get Archive Type; if the last character is a period, then the */
  81. /* extension is 2 characters long - a .gz file                   */
  82. type = right(filespec("name",arcname),3)
  83. if left(type,1) = D2C(46) then do
  84.    type = right(filespec("name",arcname),2)
  85.    end
  86.  
  87. /* Filter out the filename for use as the folder's title */
  88. windowname = filespec("name",arcname)
  89.  
  90. /* Check archive type and call appropriate unarchiver  */ 
  91. /* You should be able to add just about any archiving  */
  92. /* program; just use the part below and modify it for  */
  93. /* the appropriate program                             */
  94. select
  95.   when type = 'ZIP'
  96.      then 
  97.      do
  98.      newdir = workpath||windowname
  99.      say newdir
  100.      "pause"
  101.      workdrv
  102.      'cd 'workdir
  103.      'md 'windowname
  104.      'cd 'windowname
  105.      unzipprg arcname
  106.      if rc = 0 then
  107.         do
  108.         Call SysSetObjectData newdir, 'OPEN=DEFAULT'
  109.         end
  110.      end
  111.   when type = 'LZH'
  112.      then 
  113.      do     
  114.      newdir = workpath||windowname
  115.      workdrv
  116.      'cd 'workdir
  117.      'md 'windowname
  118.      'cd 'windowname
  119.      unlzhprg arcname
  120.      if rc = 0 then
  121.         do
  122.         Call SysSetObjectData newdir, 'OPEN=DEFAULT'
  123.         end
  124.      end
  125.   when type = 'gz'
  126.      then 
  127.      do
  128.      gzfullname = filespec("name",arcname)
  129.      if left(gzfullname,1) > D2C(34) then 
  130.         do
  131.         gzname = left(gzfullname,length(gzfullname) - 3)
  132.         end
  133.      if left(gzfullname,1) = D2C(34) then 
  134.         do
  135.         gzname = left(gzfullname,length(gzfullname) - 4)
  136.         end
  137.      gzname = D2C(34)||gzname||D2C(34)
  138.      gzdrive = filespec("drive",arcname)
  139.      gzdrive
  140.      gzpath = filespec("path",arcname)
  141.      gzpath = left(gzpath,length(gzpath) - 1)
  142.      'cd 'gzpath
  143.      ungzprg gzname
  144.      fileview gzname
  145.      gzprg gzname
  146.      end
  147. otherwise     
  148. end
  149. Call SysSetObjectData LEFT(ARCNAME,LENGTH(arcname)-1) , 'OPEN=DEFAULT'    
  150. 'cd ..'
  151.  
  152. /* End of ARCH.CMD */
  153.