home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR24 / WUZ10A.ZIP / WUZ.CMD < prev    next >
OS/2 REXX Batch file  |  1993-12-14  |  4KB  |  180 lines

  1. /* unzip/arj/pac etc and open folder */
  2. /* (c) Copyright 1993 Scott Maxwell. */
  3.  
  4. Drive    = 'E:'
  5. DestPath = 'E:\Download\temp\'
  6.  
  7. NoCommandLine = 0
  8. WaitForUnzip  = 0
  9.  
  10. arg Name
  11. if Name = '' then SIGNAL ShowUsage
  12. CurrentDir = Directory()
  13.  
  14. Yes    = 1
  15. No     = 0
  16.  
  17. Extractor.    = 'unzip -o -d'
  18. CopyTo.       = No
  19. Update.          = ''
  20. UpdateP.      = ''
  21. Fresh.        = ''
  22.  
  23. Extractor.ARC = '@arc xo'
  24. Fresh.ARC     = '@arc f'
  25. Extractor.ARJ = '@unarj x'
  26. Extractor.LZH = '@lh x /s /o'
  27. Extractor.Z   = '@compress -d'
  28. CopyTo.Z      = Yes
  29. Extractor.TAR = '@tar xf'
  30. CopyTo.TAR    = Yes
  31. Extractor.ZIP = '@unzip -o -d'
  32. Update.ZIP    = '@zip -r -u'
  33. UpdateP.ZIP   = '-x zclr.cmd zupdate.cmd zfresh.cmd'
  34. Fresh.ZIP     = '@zip -r -f'
  35.  
  36. Extractor.ZOO = '@zoo x'
  37. CopyTo.ZOO    = No
  38.  
  39.  
  40. if Length(CHARIN(Name,1,1)) \= 1 then do
  41.    say Name 'not found.'
  42.    exit(1)
  43.    END
  44. Call CHAROUT(Name)
  45.  
  46. call GetDriveSpec Name
  47.  
  48. if Ext="" then SIGNAL ShowUsage
  49. if NameOnly="" then SIGNAL ShowUsage
  50.  
  51. Dest=DestPath||NameOnly
  52.  
  53. CALL RxFuncAdd 'SysMkDir','RexxUtil','SysMkDir'
  54. CALL SysMkDir Dest
  55.  
  56. CALL RxFuncAdd 'SysFileDelete','RexxUtil','SysFileDelete'
  57. Call SysFileDelete Dest'\zclr.cmd'
  58.  
  59. Call CHAROUT Dest'\zclr.cmd',"@cd .."'0d'x'0a'x
  60. Call CHAROUT Dest'\zclr.cmd',"@detach Kill-Dir" Dest "> nul"'0d'x'0a'x
  61. Call CHAROUT Dest'\zclr.cmd',"@if '%1'=='-x' exit"'0d'x'0a'x
  62. Call CHAROUT Dest'\zclr.cmd'
  63. '@attrib +h' Dest'\zclr.cmd > nul'
  64.  
  65. if Update.Ext \= '' then do
  66.   Call SysFileDelete Dest'\zupdate.cmd'
  67.   Call CHAROUT Dest'\zupdate.cmd','@zipstrip' FullPath'0d'x'0a'x
  68.   Call CHAROUT Dest'\zupdate.cmd',Update.Ext FullPath '*' UpdateP.Ext
  69.   Call CHAROUT Dest'\zupdate.cmd'
  70.   '@attrib +h' Dest'\zupdate.cmd > nul'
  71. end
  72.  
  73. if Fresh.Ext \= '' then do
  74.   Call SysFileDelete Dest'\zfresh.cmd'
  75.   Call CHAROUT Dest'\zfresh.cmd',Fresh.Ext FullPath '*'
  76.   Call CHAROUT Dest'\zfresh.cmd'
  77.   '@attrib +h' Dest'\zfresh.cmd > nul'
  78. end
  79.  
  80. if WaitForUnzip = 0 then do
  81.   if NoCommandLine = 1 then
  82.     Call 'Open-Dir' Dest
  83.   else
  84.     if Check4OS2()=1 then
  85.       '@start "'NameOnly'.'Ext'" /l /fg post-wuz.cmd' Dest Left(Fresh.Ext,1) Left(Update.Ext,1)
  86.     else
  87.       '@start "'NameOnly'.'Ext'" /f post-wuz.cmd' Dest Left(Fresh.Ext,1) Left(Update.Ext,1)
  88. end
  89.  
  90. if Extractor.Ext \= '' then do
  91.    holdDir = DIRECTORY(Drive)
  92.    Call Directory(Dest)
  93.  
  94.    if CopyTo.Ext = Yes then do
  95.       '@copy' FullPath Dest '> nul'
  96.       '@attrib -r -h -s' FullName '> nul'
  97.       Param1 = FullName
  98.       end
  99.    else
  100.       Param1 = FullPath
  101.  
  102.    Extractor.Ext Param1
  103.  
  104.    if CopyTo.Ext = Yes then
  105.       Call SysFileDelete Param1
  106.  
  107.    end  /* Do */
  108.  
  109.   if WaitForUnzip = 1 then do
  110.     if NoCommandLine = 1 then
  111.       Call 'Open-Dir' Dest
  112.     else
  113.       if Check4OS2()=1 then
  114.         '@start "'NameOnly'.'Ext'" /l /fg post-wuz.cmd' Dest Left(Fresh.Ext,1) Left(Update.Ext,1)
  115.       else
  116.         '@start "'NameOnly'.'Ext'" /f post-wuz.cmd' Dest Left(Fresh.Ext,1) Left(Update.Ext,1)
  117. end
  118.  
  119. Call Directory holdDir
  120. Call Directory CurrentDir
  121. exit(0)
  122.  
  123.  
  124.  
  125. GetDriveSpec: procedure expose FullPath FullName NameOnly Ext
  126. arg Name
  127. fDrive = FILESPEC('Drive',Name)
  128. fPath  = FILESPEC('Path',Name)
  129. fName  = FILESPEC('Name',Name)
  130.  
  131. Dir.1 = 'DIRECTORY'()
  132. if fDrive = '' then
  133.    fDrive = FILESPEC('Drive',Dir.1)
  134.  
  135. Dir.2 = DIRECTORY(fDrive)
  136. if fPath  = '' then
  137.    fPath  = FILESPEC('Path', Dir.2)
  138.  
  139. if Left(fPath,1) \= '\' then do
  140.    Dir.3 = directory(fPath)
  141.    fPath = FILESPEC('Path', Dir.3)
  142.    Call Directory Dir.2
  143.    end
  144. Call Directory Dir.1
  145.  
  146. FullPath = fDrive||fPath||fName
  147. FullName = fName
  148.  
  149. ExtPos = LASTPOS(".",fName)
  150. if ExtPos=0 then do
  151.    Ext = ''
  152.    NameOnly = fName
  153.    end
  154. else do
  155.    Ext = SUBSTR(fName,ExtPos+1)
  156.    NameOnly = LEFT(fName,ExtPos-1)
  157.    end
  158. return
  159.  
  160.  
  161. Directory: procedure
  162.   arg Name
  163.   if Length(Name) > 3 then
  164.     if Right(Name,1) = '\' then
  165.       Name = Left(Name,LENGTH(Name)-1)
  166.   n = 'DIRECTORY'(Name)
  167.   if Right(n,1) \= '\' then
  168.     n = n'\'
  169.   return n
  170.  
  171.  
  172. Check4OS2: procedure
  173.   '@set is4os2=%_4ver'
  174.   return DATATYPE(VALUE(is4os2,,OS2ENVIRONMENT),'N')
  175.  
  176.  
  177. ShowUsage:
  178.   say "USAGE: wuz filename.[ARJ|LZH|TAR|Z|ZIP|ZOO]"
  179.   exit
  180.