home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / ALLINF.ZIP / ALLINFS.CMD next >
OS/2 REXX Batch file  |  1993-03-09  |  8KB  |  273 lines

  1. /* ALLINFS.CMD    by Leshek Fiedorowicz 1992-11-15   V 3.0        */
  2. /*                                      1993-03-10   V 3.02       */
  3. /* To create VIEW folder with all your .INF files                 */
  4. version = '3.02'
  5.  
  6. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  7. Call SysLoadFuncs
  8.  
  9. Arg Options
  10. /*
  11. ** Possible options :
  12. ** /D:list
  13. ** where 
  14. **         list - the list of drives to search
  15. **                ex: /D:CD to search only C: and D:
  16. **
  17. ** /REP
  18. **          to replace existing objects (to assign icons for example)
  19. **
  20. ** /ICO
  21. **          to assign icons if the .ICO file exists in the same directory
  22. **          and with the same name as the .INF file
  23. */
  24. Parse var Options Opt1'/D:'Drives Opt2
  25. Drives = Strip(Drives);
  26. Options = Opt1||Opt2;
  27.  
  28. If wordpos('/REP', Options) \= 0 then Do;
  29.    Parse var Options Opt1'/REP'Opt2
  30.    Options = Opt1||Opt2;
  31.    Replace = 'YES'
  32. End;
  33. Else
  34.    Replace = '';
  35.  
  36. If wordpos('/ICO', Options) \= 0 then Do;
  37.    Parse var Options Opt1'/ICO'Opt2
  38.    Options = Opt1||Opt2;
  39.    AssignIcon = 'YES'
  40. End;
  41. Else
  42.    AssignIcon = ''
  43.  
  44.  
  45. listfile = 'AllInfs.lst'
  46. IconFile = 'AllInfs.ico'
  47.  
  48. say
  49. say 'AllInfs 'version' - by Leshek Fiedorowicz; CIS#74170,2007'
  50.  
  51. If Options \= '' then /* Some unrecognized option/parameters */
  52. Do;
  53.    say
  54.    say 'ERROR: Unrecognized parameters/options, please try again.'
  55.    say '      Supported options are:'
  56.    say '      /D:list'
  57.    say '      where:'
  58.    say '            list - the list of drive letters to search if you '
  59.    say "                   don't wish all drives to be searched."
  60.    Exit 99;
  61. End;
  62.  
  63.  
  64. say
  65. say 'Searching your drives for *.INF files.  Please wait... '
  66. Call CSeeAll;
  67. say
  68.  
  69. if lines(listfile) = 0 then
  70. do;
  71.    say
  72.    say '*** Warning: AllInfs list file not found, object will have names same'
  73.    say '             as files names.  Do you want to continue (Y/anything) ?'
  74.    pull ans
  75.    if strip(ans) \= 'Y' then do;
  76.       say '    Place AllInfs.LST in current directory and try again.'
  77.       say '    Thank you for using AllInfs 'version'.... Leshek Fiedorowicz.'
  78.       say
  79.       exit 4;
  80.    end;
  81. end;
  82.  
  83. /* read list file */
  84. cnt = 0;
  85. list. = '';
  86. do while lines(listfile);         /* Read input file */
  87.    cnt = cnt + 1;
  88.    list.cnt = linein(listfile);
  89. end;
  90. list.0 = cnt;
  91.  
  92. icf. = '';
  93. /* Find icon file (first occurence on the current drive           */
  94. rc = SysFileTree('\'IconFile, 'icf', 'SF')
  95. parse var icf.1 date time size attribs IconFileFullName;
  96. IconFileFullName = Strip(IconFileFullName );
  97.  
  98. /* Create Foler on the Desktop                                    */
  99. classname = 'WPFolder';
  100. title = 'All IPFs';
  101. location = '<WP_DESKTOP>';
  102. setup='OBJECTID=<All_IPFs>;'||,
  103.       'ICONVIEW=FLOWED;'||,
  104.       'ICONFILE='IconFileFullName;
  105.       /* SORT= LE=filename */
  106. rc = SysCreateObject(classname, title, location, setup);
  107. if rc \= 1 then do;
  108.    say 'Unable to create <All IPFs> Folder, it may already exist.';
  109.    say 'Processing Continues ... new IPFs will be added ... ';
  110.    Say
  111. end;
  112.  
  113. errors = '';
  114. errors.0 = 0;
  115.  
  116. say 'In the following display:'
  117. say '   . found file with .INF extension but not in a VIEW format.';
  118. say '   - found file with .INF but unable to create corresponding object.';
  119. say '   + found file with .INF and succesfully created object.';
  120. Say 'Please wait...';
  121.  
  122. count = 0;
  123. /* Main processing loop */
  124. do in = 1 to AllFile.0;
  125.    /* rc= charout(,'.'); */
  126.    parse var AllFile.in date time size attribs infile'.'ext;
  127.    InFile = Strip(InFile);
  128.    LastBSlashPos = Lastpos('\', Infile);
  129.    InfPath = Substr(InFile, 1, LastBSlashPos);
  130.    InFile = Substr(InFile, (LastBSlashPos + 1));
  131.    object = infpath||infile||'.INF';
  132.    icon = infpath||infile||'.ICO';
  133.    firstline = linein(object,1,1);
  134.    call Stream object, 'c', 'close';
  135.    if substr(firstline,1,4) \= 'HSP'||'01'x then do;
  136.       rc= charout(,'.');
  137.       iterate;                  /* Ignore non VIEWable files              */
  138.    end;
  139.    title = infile infpath;
  140.    infile = translate(infile)   /* Uppercase file name                    */
  141.    do k = 1 to list.0
  142.       parse var list.k fl ttl
  143.       if fl = infile then do;
  144.          title = strip(ttl);
  145.          leave k;
  146.       end;
  147.    end;
  148.    if title = 'EXCLUDE' then
  149.       iterate;                  /* Ignore specified files                 */
  150.  
  151.    ClassName = 'WPProgram';
  152.    /* Title = Title;                                                      */
  153.    Location = '<All_IPFs>';
  154.    Setup = 'PROGTYPE=PM;'||,
  155.            'EXENAME=VIEW.EXE;'||,
  156.            'PARAMETERS='object';'||,
  157.            'OBJECTID=<'object'>;';
  158.  
  159.    If AssignIcon \= '' then     /* If /ICO option - try to assign the icon*/
  160.       Setup = Setup||'ICONFILE='Icon';';
  161.  
  162.    If Replace \= '' then        /* If /REP option was specified replace   */
  163.       duplicateflag='ReplaceIfExists'; /* existing objects                */
  164.      else
  165.       duplicateflag='FailIfExists';
  166.  
  167.    rc = SysCreateObject(ClassName, Title, Location, Setup, duplicateflag);
  168.  
  169.    if rc = 1 then do;
  170.       rc= charout(,'+');
  171.       count = count + 1;
  172.    end;
  173.    else do;
  174.       rc= charout(,'-');
  175.       errors.0 = errors.0 + 1;
  176.       i = errors.0;
  177.       errors.i = object;
  178.    end;
  179. end;
  180.  
  181. say
  182.  
  183. if errors.0 \= 0 then do;
  184.    say
  185.    if error.0 >1 then
  186.       txt = 'files have'
  187.    else
  188.       txt = 'file has'
  189.  
  190.    say '*** The following 'txt' not been processed correctly (may already exist):'
  191.    ns = 22;
  192.    done = 0;
  193.    do i = 1 to errors.0
  194.       if ((i - done) //ns = 0) then do;
  195.          Say 'Press any key to continue...';
  196.          Pull;
  197.          done = (i - done) + done;
  198.          ns = 22;
  199.       End;
  200.       tx = right(i,7)': 'errors.i
  201.       say tx
  202.       If length(tx) > 80 then
  203.          ns = ns -1;
  204.    end;
  205. end;
  206.  
  207. say
  208. select
  209.   when count = 0 then
  210.        say 'No objects created.'
  211.   when count = 1 then
  212.        say 'One .INF object has been created in <All IPFs> folder on your desktop.';
  213.   Otherwise
  214.        say count' INF objects have been created in <All IPFs> folder on your desktop.';
  215. end;
  216.  
  217. say 'Thank you for using AllInfs 'version' .... Leshek Fiedorowicz.'
  218. say
  219.  
  220. exit 0;
  221.  
  222. /* SEEALL     - by Leshek Fiedorowicz                             */
  223. /* To find all file occurences on any drive, using wildcard       */
  224. CSeeAll:
  225.  
  226. file = '*.INF'
  227.  
  228. If Drives = '' then do;       /* If no drives specified in the /D:*/
  229.                               /*   option - search all drives     */
  230.    /* Find all logical drives available - onto Drive. stem        */
  231.    AllDrives = SysDriveMap('c:', 'USED');
  232. End;
  233. Else Do;                      /* If drive were specified in the /D*/
  234.                               /* option - build the drives list   */
  235.    AllDrives = '';
  236.    Do sai = 1 to length(Drives);
  237.       AllDrives = AllDrives Substr(Drives,sai,1)||': ';
  238.    End;
  239. End;
  240.  
  241. Drive. = '';
  242. cnt = 0;
  243. Do While AllDrives \= ''
  244.    cnt = cnt + 1;
  245.    Parse var AllDrives Drive.cnt AllDrives
  246. End;
  247. Drive.0 = cnt;
  248.  
  249. if Drive.0 = 0 then do;
  250.    say 'Error : no logical drives found !'
  251.    Exit 8;
  252. End;
  253.  
  254. /* Check for the file on all available logical drives             */
  255. AllFile. = '';
  256. AllCnt = 0;
  257. Do d = 1 to Drive.0;
  258.    c1=Substr(Drive.d,1,1); c2=Substr(Drive.d,2,1);
  259.    rc= charout(,c1); rc= charout(,c2); rc= charout(,'  ');
  260.    rc = SysFileTree(Drive.d'\'file, 'file', 'SF')
  261.    If rc \= 0 then say 'ERROR in SysFileTree call - 'rc
  262.    do i=1 to file.0
  263.       AllCnt = AllCnt + 1;
  264.       AllFile.AllCnt = file.i
  265.    End;
  266. End;
  267. AllFile.0 = AllCnt;
  268. rc= charout(,'0A'x);
  269. rc= charout(,'0D'x);
  270.  
  271. Return;
  272.  
  273.