home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / con2v766.zip / cn2_76_6.zip / util / dsk.cmd < prev    next >
OS/2 REXX Batch file  |  2000-09-13  |  5KB  |  139 lines

  1. /*---------------------------------------------------------------------------
  2. ** IBM DSK & VMDISK Viewer filter & Extract wrapper v0.03 for Connect/2
  3. **
  4. ** Accepts uncompressed DSK (created by SAVEDSKF or DISKIMAGE), VMDISK
  5. ** (created by VMDISK) and PM Diskcopy own disk image formats
  6. **
  7. ** Uses PMDIMGEX.EXE v1.0b from the package PM Diskcopy 2.4 (PMD24E.ZIP)
  8. **
  9. ** Filters output from PMDIMGEX.EXE:
  10. **     22 606  19.05.2000  15:15  A---  FIX\REQ.1\SRV_PROD.REQ
  11. ** to format suitable for CN:
  12. **     DOCUMENT.TXT        34987  05.21.95  12:54:08
  13. **
  14. ** Installation (place this file to path_to_CN\util and fill in an archiver
  15. ** record as shown):
  16.  
  17. ╔[■]══════════════════ Modify user defined Archiver setup ═════════════════════╗
  18. ║                                                                              ║
  19. ║  Trademark          IBM DSK Image               List modifier          @     ║
  20. ║  View command       pmdimgex.exe -v $ARC $MSG($CN\util\dsk.cmd)              ║
  21. ║                                                 Default extension      dsk   ║
  22. ║  View dir command                                                            ║
  23. ║  Packer name                                    Exec options                 ║
  24. ║  Unpacker name      $CN\util\dsk.cmd $USR        [ ] Swap main body          ║
  25. ║  Extract            e $ARC $SRC                  [ ] Switch to user screen   ║
  26. ║  Extract with dirs  x $ARC $SRC                  [X] Load COMMAND.COM        ║
  27. ║  Add                                             [X] Enable Win95 LFN        ║
  28. ║  Add with dirs                                   [ ] Prompt on overwrite     ║
  29. ║  Move                                                                        ║
  30. ║  Move with dirs                                 Name mask  *.dsk             ║
  31. ║  Delete                                                                      ║
  32. ║  Test                                           Environment condition        ║
  33. ║  Password                                                               ▐▌  ║
  34. ║                                                                              ║
  35. ╚══════════════════════════════════════════════════════════════════════════════╝
  36.  
  37. **
  38. ** NOTES: 1. PMDIMGEX.EXE should be somewhere in the path or you have to
  39. **           adjust the View command above and the variable G.extractor below.
  40. **        2. If the extraction of big amount of files does not work (when
  41. **           you extract a big directory, for example) lower the value of the
  42. **           G.max_arg_len variable.
  43. **-------------------------------------------------------------------------*/
  44.  
  45. G.extractor     = 'pmdimgex.exe'
  46. G.max_arg_len   = 1010
  47.  
  48. parse arg cmd arc src
  49. cmd = translate( cmd )
  50.  
  51. select
  52.     when cmd = 'E'  then call extract arc, src, '-j'
  53.     when cmd = 'X'  then call extract arc, src
  54.     when cmd = ''   then call filter
  55.     otherwise nop
  56. end
  57.  
  58. exit
  59.  
  60. filter: procedure expose G.
  61.  
  62.     list_started = 0
  63.  
  64.     do while( lines() \= 0 )
  65.         str = linein()
  66.         if( str = '' ) then iterate
  67.         if( \list_started &,
  68.             str = '---------  ----------  -----  ----  ------------',
  69.           ) then do
  70.             list_started = 1
  71.             iterate
  72.         end
  73.         if( list_started ) then do
  74.             i = pos( '.', str )
  75.             if( i < 5 ) then iterate
  76.             fsize = substr( str, 1, i-3 )
  77.             parse value substr( str, i-2 ) with fdate ftime . fname
  78.  
  79.             /* fix pmdimgex bug with thousand delimiter */
  80.             str = translate( fsize, ' ', 'FF'x )
  81.             fsize = ''
  82.             do i = 1 to words( str )
  83.                 fsize = fsize||word( str, i )
  84.             end
  85.             if( fsize = '<DIR>' ) then iterate
  86.  
  87.             parse var fdate s1'.'s2'.'s3
  88.             fdate = s2'.'s1'.'right( s3, 2 )
  89.  
  90.             say '"'strip( fname )'"' fsize fdate ftime
  91.         end
  92.     end
  93.  
  94.     return
  95.  
  96. extract: procedure expose G.
  97.  
  98.     parse arg arc, src, add_sw
  99.  
  100.     /* fix pmdimgex bug with backslashes */
  101.     dest = strip( directory(), 'T', '\' )
  102.  
  103.     arg_beg = add_sw arc
  104.     arg_end = '-d' dest '1>con 2>con'
  105.     max_len = G.max_arg_len - length( arg_beg arg_end ) - 1
  106.  
  107.     n = 1
  108.     if( left( src, 1 ) = '@' ) then do
  109.         list = strip( src, 'L', '@' )
  110.         src.1 = ''
  111.         do while lines( list )
  112.             str = fixslash( linein( list ) )
  113.             if( length( src.n str ) > max_len ) then do
  114.                 n = n + 1
  115.                 src.n = ''
  116.             end
  117.             src.n = src.n str
  118.         end
  119.         call lineout list
  120.     end
  121.     else do
  122.       src.1 = fixslash( src )
  123.     end
  124.  
  125.     do i = 1 to n
  126.         G.extractor arg_beg src.i arg_end
  127.     end
  128.  
  129.     return
  130.  
  131. fixslash: procedure
  132.  
  133.     /* fix pmdimgex bug with backslashes */
  134.     if( arg(1) \= '' & pos( '\', arg(1) ) = 0 ) then
  135.         return '"\'strip( arg(1), 'B', '"' )'"'
  136.  
  137.     return arg(1)
  138.  
  139.