home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxls02.zip / RXLS02.CMD
OS/2 REXX Batch file  |  1994-10-28  |  4KB  |  57 lines

  1. /*------------------------------------------------------------------------*\
  2. |                                                                          |
  3. | 9412LS01.CMD (rxls02) - Compare two directories using associative arrays |
  4. |                                                                          |
  5. \*------------------------------------------------------------------------*/
  6. call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'         /* 0006 */
  7. call SysLoadFuncs                                                 /* 0007 */
  8.                                                                   /* 0008 */
  9. directory_1 = 'd:\*.*'                                            /* 0009 */
  10. directory_2 = 'e:\*.*'                                            /* 0010 */
  11.                                                                   /* 0011 */
  12. /*-----------------------*\                                       /* 0012 */
  13. |  Process 1st directory  |                                       /* 0013 */
  14. \*-----------------------*/                                       /* 0014 */
  15. index_1. = 0                        /* initialize all elements */ /* 0015 */
  16. call SysFileTree directory_1, 'tree_1', 'FO'                      /* 0016 */
  17. do t1 = 1 to tree_1.0                                             /* 0017 */
  18.    subscript = FILESPEC( 'P', tree_1.t1 ) ||,                     /* 0018 */
  19.                FILESPEC( 'N', tree_1.t1 )                         /* 0019 */
  20.    index_1.subscript = t1                                         /* 0020 */
  21. end                                                               /* 0021 */
  22.                                                                   /* 0022 */
  23. /*-------------------------------*\                               /* 0023 */
  24. |  Process 2nd directory vs. 1st  |                               /* 0024 */
  25. \*-------------------------------*/                               /* 0025 */
  26. index_2. = 0                        /* initialize all elements */ /* 0026 */
  27. call SysFileTree directory_2, 'tree_2', 'FO'                      /* 0027 */
  28. do t2 = 1 to tree_2.0                                             /* 0028 */
  29.    subscript = FILESPEC( 'P', tree_2.t2 ) ||,                     /* 0029 */
  30.                FILESPEC( 'N', tree_2.t2 )                         /* 0030 */
  31.    index_2.subscript = t2                                         /* 0031 */
  32.    if index_1.subscript > 0 then                                  /* 0032 */
  33.       do                                                          /* 0033 */
  34.          index_1.subscript = -1     /* indicate matching entry */ /* 0034 */
  35.          iterate                                                  /* 0035 */
  36.       end                                                         /* 0036 */
  37.    say directory_1          ||,                                   /* 0037 */
  38.        ' does not contain ' ||,                                   /* 0038 */
  39.        subscript                                                  /* 0039 */
  40. end                                                               /* 0040 */
  41.                                                                   /* 0041 */
  42. /*--------------------------------------------*\                  /* 0042 */
  43. |  Process unmatched entries in 1st directory  |                  /* 0043 */
  44. \*--------------------------------------------*/                  /* 0044 */
  45. do t1 = 1 to tree_1.0                                             /* 0045 */
  46.    subscript = FILESPEC( 'P', tree_1.t1 ) ||,                     /* 0046 */
  47.                FILESPEC( 'N', tree_1.t1 )                         /* 0047 */
  48.    if index_1.subscript > 0 then                                  /* 0048 */
  49.       do                                                          /* 0049 */
  50.          say directory_2          ||,                             /* 0050 */
  51.              ' does not contain ' ||,                             /* 0051 */
  52.              subscript                                            /* 0052 */
  53.       end                                                         /* 0053 */
  54. end                                                               /* 0054 */
  55.                                                                   /* 0055 */
  56. exit                                                              /* 0056 */
  57.