home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / mfil130a.zip / extr2dir.cmd < prev    next >
OS/2 REXX Batch file  |  1994-05-12  |  9KB  |  290 lines

  1. /* extr2dir.cmd*/
  2. echo off
  3. parse upper arg qual drive path file ext
  4. fqual = STRIP(qual)
  5. ldriv = STRIP(drive)
  6. lpath = STRIP(path)
  7. lfile = STRIP(file)
  8. lext  = STRIP(ext)
  9.      
  10. /*
  11.  
  12.     This code has been pirated from Virexx.cmd by Ronald Van Iwaarden
  13.     1:104/338@fidonet 12 May, 1994
  14. */
  15. /* ---------------------------------------------------------------------------*/
  16. /*   - - - - - - - - - -   C O N F I G U R A T I O N - - - - - - - - - - -    */
  17. /* -----  Set these variables for your System ------------------------------- */
  18.  
  19. /* 1) LISTS  (lists of file extensions and how to deal with them)                                                                */
  20. /* ***** THESE MUST BE UPPER CASE OR THEY WONT WORK !!!!!    ****** */
  21.  
  22. arc_list='.ZIP .LZH .ARC .ARJ .ZOO'     /* list of defined achives */
  23.  
  24. /* 2) VARIABLES */
  25.  
  26. /* 3) PATHS (paths to various files and directories needed by VIREXX */
  27. /* ****NOTE**** Change only UPPER CASE PARTS*/
  28. tempdir  = 'e:\tmp\readme'      /* dir for testing lnode = 1,2 ect.*/
  29.  
  30.  
  31. /* 4) COMMANDS (Command lines for various programs called by VIREXX)*/
  32. /*    NOTE: Virexx appends the filename to the end of the archiver commands*/
  33. /*    so the space at the end is important*/
  34.  
  35. lh_command='lh x /o /i '                /* command to extract .lzh file*/
  36.                                         /* this ones for 32bit LH2 2.12*/
  37. zip_command1 ='unzip -oj '              /* command to extract .ZIP files*/
  38.                                         /* with version 1.x signature*/
  39.                                         /* this ones for PKUNZIP2 1.02*/
  40. zip_command2 ='unzip -oj '              /* command to extract .ZIP files*/
  41.                                         /* with version 2.x signature*/
  42.                                         /* this ones for InfoZip unzip 5.0*/
  43. arj_command ='unarj e '                 /* unarj command for Robert Jungs*/
  44.                                         /* Demo version 2.10 Unarj*/
  45. /* arj_command ='gnunarj x '*/          /* unarj command for 32bit GNU port*/
  46.                                         /* of R. Jungs Demo Unarj 2.30*/
  47. arc_command ='arc2 xo '                 /* command to extract archive using*/
  48.                                         /* SEA's ARC2 ver 6.00*/
  49. zoo_command ='zoo e:O '                 /* command to extract archive using*/
  50.                                         /* ZOO 2.1 (renamed to ZOO2.exe)*/
  51. comment_command = 'zip -z -k '          /* command to add comment to .zip file*/
  52.  
  53. zipdir = ''                             /* path to arcive subdirectory */
  54.  
  55. /* 5) SWITCHES (switches for various functions. Use 1 for ON, 0 for OFF)*/
  56.  
  57. zipcomment = 1                          /* Add bbs comment to .zip files*/
  58. dbase      = 1                          /* write entry to file database*/
  59. /* -------------------------------------------------------------------------- */
  60. /*    - - - - -  E N D    O F    C O N F I G U R A T I O N  - - - - - - -     */
  61. /* ---------------------------- Main Program -------------------------------- */
  62. /*trace all*/
  63. call initialize                        /* initialize program */
  64. fullname = fqual                       /* full pathname to file(s) */
  65.  
  66.  
  67. /* Look for all files with the specified name*/
  68.  
  69.  
  70. call SysFileTree fullname,'lfile','FSO'
  71. /* If any exist then process them*/
  72.  
  73. say 'To where would you like to extract the file? '
  74.  
  75. pull destdir
  76.  
  77.  
  78. if lfile.0 > 0 then do
  79.  
  80.  
  81.  
  82. /* Perform check for all of the files*/
  83. /* This version is made for generic scans of subdirectories*/
  84. do filecnt = 1 to lfile.0
  85.  
  86. /* Get the first/next file to process*/
  87. fullname = TRANSLATE(lfile.filecnt)     /* full pathname to file */
  88.  
  89. filename = lfile||lext
  90.  
  91.  
  92. lpath = ldrive||lpath
  93.  
  94.  
  95. select
  96.   when POS(lext,arc_list)>0 then
  97.     call unarchive
  98.  
  99. end /* select */
  100.  
  101. 'pause'
  102.  
  103. cleandest
  104.  
  105.  
  106. end /* Loop for all files*/
  107. end /* Files exist*/
  108. cleanup:
  109.   call RxFuncDrop 'SysFileTree'
  110. exit
  111.  
  112. /* ------------ end -  main program ------------------ */
  113.  
  114.  
  115. cleandest:
  116.  
  117.  dontask = '/N'
  118.  
  119.  if stream(destdir||'\*.*','c','query exist')  <> '' then
  120.    'ERASE 'destdir'\*.* 'dontask   /* cleanup dest dir */
  121.  
  122.  return
  123.  
  124.  
  125.  
  126.  
  127. /* ----- Subroutine Initialize ----------------------- */
  128. initialize:
  129.  if lext = '' then
  130.    call USAGE
  131.  dontask = '/N'
  132.  call RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree'
  133.  call RxFuncAdd 'SysMkDir','RexxUtil','SysMkDir'
  134.  call RxFuncAdd 'SysRmDir','RexxUtil','SysRmDir'
  135.                                    /* make sure Rexxutils loaded */
  136.  call SysFileTree tempdir,'dir','DO'
  137.  if dir.0 = 0 then
  138.    call SysMkDir tempdir
  139.  
  140.  if stream(tempdir||'\*.*','c','query exist')  <> '' then
  141.    'ERASE 'tempdir'\*.* 'dontask   /* cleanup test dir */
  142.  tempdir.0 = 0 /* No arcs within arcs yet*/
  143.  
  144.  archsize = 0
  145.  nested = NO                                 /* clear nested */
  146.  ZIPTYPE =''
  147.  
  148.  
  149. return
  150.  
  151. /* ----- End - Initialize ---------------------------- */
  152.  
  153. /* ----- Subroutine Unarchive ------------------------ */
  154.  
  155. unarchive:
  156.  ffname = fullname
  157.  fname = filename
  158.  testdir = tempdir
  159.  signature = CHARIN(ffname,1,6)
  160.  temp = stream(ffname,'c','close')
  161.  Select
  162.  
  163.  PARSE VALUE destdir WITH drive ':' relpath
  164.  driveext = drive||':'
  165.  drivext
  166.  'CD 'destdir
  167.  
  168.  
  169.    when (substr(signature,1,5) = 'PK') then do  /* version 2.x zip file    */
  170.      call unzip2
  171.    end /* do */
  172.  
  173.    when (substr(signature,1,4) = 'PK') then do  /* version 1.x zip file    */
  174.      call unzip1
  175.    end /* do */
  176.  
  177.    when (substr(signature,3,3) = '-lh'  ) then do      /* .lzh file          */
  178.      call unlzh
  179.    end /* do */
  180.  
  181.    when (substr(signature,1,2) = '`Ω'   ) then do      /* .arj file          */
  182.      call unarj
  183.    end /* do */
  184.  
  185.    when (substr(signature,1,3) = 'ZOO'  ) then do      /* .zoo file          */
  186.      call unzoo
  187.    end /* do */
  188.  
  189.    when lext = '.ARC' then do                            /* .arc file           */
  190.      call unarc
  191.    end /* do */
  192.  
  193.    otherwise do
  194.      status = 'BAD'
  195.    end /* do */
  196.  
  197. end /* select */
  198.  
  199.  
  200. return
  201.  
  202. /* ----------- End - unarchive -----------------------------*/
  203.  
  204.  
  205. /* ------ Unzip - run unzip on filename ------- */
  206. unzip1:
  207.   'CD 'testdir
  208.   zipdir||zip_command1' 'ffname' readme read.me readme.txt'/* unzip file */
  209. return
  210.  
  211. /* end unzip1 */
  212. /* ------ Unzip2 - run unzip on version 2.x filename ------- */
  213. unzip2:
  214.  'CD 'testdir
  215.  zipdir||zip_command2' 'ffname' readme read.me readme.txt'/* unzip file */
  216. return  
  217.  
  218. /* end unzip2 */
  219.  
  220.  
  221. /* ------ Unzoo - run zoo on filename ------- */
  222. unzoo:
  223.   'CD 'testdir
  224.   zipdir||zoo_command' 'ffname' readme read.me readme.txt'
  225. return
  226.  
  227. /* end unzoo */
  228.  
  229.  
  230. /* ---------  unarj -- run unarj on filename --------------- */
  231. unarj:
  232.      /* written for Robert Jung's Unarj 2.10                                */
  233.      /* this section will copy the file to the test file dir and also copy  */
  234.      /* unarj to the same directory, run unarj and cleanup afterwards. If   */
  235.      /* your test dir is on a different drive be sure to fix this section   */
  236.  
  237.   'CD 'testdir
  238. /*     unarj e fname                                     /* unarj file        */
  239. */
  240.   zipdir||arj_command' 'ffname' readme read.me readme.txt'
  241.  
  242. return
  243.  
  244. /* end unarj */
  245.  
  246. /* ----------- unlzh -- unlzh filename ----------- */
  247.          
  248. unlzh:
  249.   /* written for LH32  2.21    */
  250.   'COPY 'ffname testdir                          /* copy file to test dir  */
  251.   'CD 'testdir
  252.   zipdir||lh_command' 'ffname' readme read.me readme.txt' /* unlzh file */
  253. return
  254.  
  255. /* end unlzh */
  256.  
  257. /* ----- unarc -- unarc filename using ARC2 ---- */
  258.  
  259. unarc:
  260.   /* written for ARC2 6.00p                                              */
  261.   /* this section will copy the file to the test file dir and also copy  */
  262.   /* arc2 to the same directory, run arc2 and cleanup afterwards. If     */
  263.   /* your test dir is on a different drive be sure to fix this section   */
  264.  
  265.   'COPY 'ffname testdir                          /* copy file to test dir  */
  266.   'CD 'testdir
  267.   zipdir||arc_command' 'ffname' readme read.me readme.txt'  /* unarc file   */
  268. return
  269.  
  270. /* end unarc  */
  271.  
  272.  
  273.  
  274.  
  275. USAGE:
  276. say ' '
  277. say ' getreadm.cmd a .cmd file to extract and view a readme file'
  278. say ' '
  279. say ' USAGE: getreadm d:\path\filename.exe d: path\ filename .ext'
  280. say ' '
  281. say ' path\   = path to file to be checked INCLUDING trailing \'
  282. say ' '
  283. say ' filename   = the name of the file with no path or extension'
  284. say ' '
  285. say ' .ext       = the file extension including the . '
  286. say ' '
  287. say ' '
  288. signal CLEANUP
  289. return
  290.