home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / ZTL17.ZIP / ZTL.CMD < prev    next >
OS/2 REXX Batch file  |  1993-02-09  |  7KB  |  234 lines

  1. /**/signal STARTZTL/*---> ZTL /? for help <----*/
  2. /*
  3.     ╔╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╗
  4.     ╣              Zip to Lzh 1.7               ╠
  5.     ╣            ------------------             ╠
  6.     ╣   (or Any archive to Any other archive)   ╠
  7.     ╣                ----------                 ╠
  8.     ╣                    ZTL                    ╠
  9.     ╚╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╝
  10.  
  11.     ---------------------------------------------
  12.    [ totally freeware by Tim Middleton 1:250/202 ]
  13.     ---------------------------------------------
  14.  
  15. *** Modify the following few variables to reflect the names and
  16. *** command lines of your archivers.  Any number of archivers is
  17. *** supported but must have the format:
  18.  
  19.     EXT.1='archiver unarchive_command'
  20.     EXT.2='archiver archive_command'
  21.  
  22.         EXT is the extension of the archive format.
  23.         See defaults directly below and all should be clear.
  24.  
  25.                     Archiver Definitions . . .                  */
  26. ARCHIVERS:
  27.  
  28.     ZIP.1='gnuunzip'
  29.     ZIP.2='pkz2'
  30.     ARJ.1='unarj e'
  31.     ARJ.2=''             /* there is no arj compression for os/2 YET */
  32.     LZH.1='lh x /o'
  33.     LZH.2='lh a /o'
  34.  
  35.              /* end of archiver defintions */
  36. return
  37. PROCESS: procedure                /* MODIFY THIS!!!!!!!! */
  38. /********************************************************
  39.  ***  This routine is run on the unarchived files     ***
  40.  ***  Add here any files you might like deleted.      ***
  41.  ***  If you don't use McAfee's Scan.exe then delete  ***
  42.  ***  That line.... add whatever you want in quotes.  ***
  43.  ********************************************************/
  44.  
  45.     'Os2Scan *.* /nomem /nopause /noexpire'
  46.     'del toxic.doc >nul'
  47.     'del readme.ros >nul'
  48.  
  49. /********* Okay, don't modify any more!! ************/
  50. rc=0
  51. return
  52. HELP:
  53. cls;say;say id;say
  54. say'The command structure is:';say
  55. say'ZTL [<filespec>] [/b] [/d] [/i] [/t<archive-type>] [/w<drive>] [/?]'
  56. say;say'    <filespec> - The file(s) to convert. (default is *.zip)'
  57. say'            /b - Update FILES.BBS with new extension.'
  58. say'            /d - do NOT delete the original archive'
  59. say'            /i - do NOT convert internal archives'
  60. say'            /t - extension of target archive. (default is LZH)'
  61. say'            /w - is an optional work drive (ie. E:)'
  62. say'            /? - this screen';say
  63. say'                (for more details see the ZTL.DOC'
  64. say'           to change archiver commands see program listing)'
  65. exit
  66. STARTZTL:
  67. echo off
  68. call ARCHIVERS
  69. commandline=arg(1)
  70. id='ZTL Archive Converter v1.7  (ZTL /? for help)'
  71. if pos(commandline,' /?')>0 then signal HELP
  72. filemask=subword(commandline,1,1)
  73. if substr(filemask,1,1)='/'|filemask='' then filemask='*.zip'
  74. if right(filemask,1)='*' then filemask=filemask'.zip'
  75. call RxFuncAdd 'SysLoadfuncs','RexxUtil','SysLoadFuncs'
  76. call SysLoadFuncs
  77. oaext=right(filemask,3)
  78. parse upper var oaext oaext
  79. x=pos('/t',commandline)+pos('/T',commandline)
  80. if x=0 then x='LZH'
  81. if x<>'LZH' then x=substr(commandline,x+2,3)
  82. parse upper var x taext
  83. oacmd=value(oaext'.1')
  84. tacmd=value(taext'.2')
  85. say;say 'Getting directory......'
  86. call GETFILES
  87. pth=left(word(file.1,5),lastpos('\',word(file.1,5))-1)
  88. sd=directory()
  89. x=pos('/w',commandline)+pos('/W',commandline)
  90. if x>0 then call WORKDRV
  91. call WORKDIR
  92. do l=1 to file.0
  93. say;say id;say
  94. file=word(file.l,5)
  95. type='main'
  96. call CONVERT
  97. x=pos('/b',commandline)+pos('/B',commandline)
  98. if x>0 then call BBS
  99. x=pos('/d',commandline)+pos('/D',commandline)+rc
  100. if oaext=taext then x=x+1
  101. if x=0 then say "Now DELETING original archive..."
  102. if x=0 then call sysfiledelete(pth'\'root'.'oaext)
  103. end
  104. DONE:
  105. cd..
  106. rd ztl.ztl
  107. x=directory(sd)
  108. filemask=left(filemask,length(filemask)-4)'.'taext
  109. call sysfiletree filemask, 'dir', 'f'
  110. ototal=0; ttotal=0; total=0
  111. say;say 'ZTL Summary:';say
  112. say '  Before     After   Result   Filename'
  113. say ' --------  --------  ------   -----------'
  114. do l=1 to file.0
  115. do x=1 to dir.0
  116. filemask=filespec('name',left(word(file.l,5),length(word(file.l,5))-4)'.'taext)
  117. if filemask<>filespec('name',word(dir.x,5)) then iterate
  118. file=format(word(file.l,3),9)' 'format(word(dir.x,3),9)' '
  119. file=file' 'format(word(file.l,3)-word(dir.x,3),6)
  120. say file'   'filespec('name',word(dir.x,5))
  121. ototal=ototal+word(file.l,3)
  122. ttotal=ttotal+word(dir.x,3)
  123. total=total+1
  124. end
  125. end
  126. say ' ========  ========  ======   ==========='
  127. file=format(ototal,9)' 'format(ttotal,9)' '
  128. say file' 'format(ototal-ttotal,6)'   ('total' files)';say
  129. exit
  130. BBS: procedure expose root oaext taext pth
  131. call sysfiletree pth'\files.bbs','dir','F'
  132. if dir.0<>0 then do
  133. status=stream(pth'\files.bbs','C','open')
  134. if status="READY:" then do while lines(pth'\files.bbs')=1&status<>"UNKNOWN"
  135. file=linein(pth'\files.bbs')
  136. parse upper var file file
  137. if pos(root'.'oaext,file)>0 then do
  138. rc=stream(pth'\files.bbs','C', 'SEEK -'length(file)+2)
  139. rc=charout(pth'\files.bbs',root'.'taext)
  140. if rc>0 then say '------> error writing to 'pth'\FILES.BBS <------'
  141. status=stream(pth'\files.bbs','C','close')
  142. status=stream(pth'\files.bbs','S')
  143. end
  144. end
  145. if status<>"UNKNOWN" then do
  146. say '------> 'root'.'oaext' not found in 'pth'\FILES.BBS <------'
  147. status=stream(pth'\files.bbs','C','close')
  148. end
  149. end
  150. if dir.0=0 then say '------> 'pth'\FILES.BBS not found! <------'
  151. return
  152. CHECKINT: procedure expose oaext taext oacmd tacmd id commandline
  153. filemask='*.*'
  154. call GETFILES
  155. pth='..'
  156. l=1
  157. do x=1 to file.0
  158. if right(file.x,3)=oaext then do
  159. say '!! INTERNAL ARCHIVE DETECTED !!'
  160. call WORKDIR
  161. file=file.x
  162. type=internal
  163. call CONVERT
  164. 'cd..'
  165. 'rd ztl.ztl'
  166. call SysFileDelete(word(file,5))
  167. l=l+1
  168. end
  169. end
  170. return
  171. CONVERT:
  172. say 'Getting file to convert...'
  173. root=left(filespec('name',file),length(filespec('name',file))-4)
  174. say 'Converting' type 'archive #'l': 'root'.'oaext' -> 'root'.'taext;say
  175. interpret 'oacmd pth"\"root'
  176. if RC>0 then do
  177. call ERROR
  178. return;end
  179. if (pos('/i',commandline)+pos('/I',commandline))=0 then call CHECKINT
  180. call PROCESS
  181. interpret 'tacmd pth"\"root "*.*"'
  182. if RC>0 then do
  183. call ERROR
  184. return;end
  185. 'del *.* /y /q >nul'
  186. return
  187. DIREXISTS:
  188. Say 'Work directory already exists: now deleting!'
  189. 'del .\ztl.ztl /y >nul'
  190. 'rd ztl.ztl'
  191. return
  192. ERROR:
  193. say;say '************ ERROR *************'
  194. say ' Skipping 'pth'\'root'.'oaext
  195. say '********************************';say
  196. 'del *.* /y /q'
  197. return
  198. say 'Exiting ZTL...'
  199. exit
  200. GETFILES:
  201. call sysfiletree filemask,'file','F'
  202. if file.0=0 then signal NOFILES
  203. return
  204. NOFILES:
  205. say
  206. say There do not seem to be any files to convert.
  207. exit
  208. WORKDIR: procedure
  209. call sysfiletree 'ztl.ztl','x','D'
  210. if x.0=1 then call DIREXISTS
  211. 'md ztl.ztl'
  212. 'cd ztl.ztl'
  213. return
  214. WORKDRV:
  215. wd=substr(commandline,x+2,2)
  216. if right(wd,1)<>':' then do
  217. say '`'wd'` is not a valid work drive.'
  218. say
  219. exit
  220. end
  221. wd
  222. if rc<>0 then do
  223. say '`'wd'` is not a valid work drive.'
  224. say
  225. exit
  226. end
  227. 'cd\'
  228. return
  229.  
  230. /*=================================================================*/
  231. /* Hope you find this useful.  Send me any suggestions via NetMail.*/
  232. /* Tim Middleton 1:250\202              Toronto, Canada, Feb. 1993 */
  233. /*-----------------------------------------------------------------*/
  234.