home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / ADDICO11.ZIP / ADDICON.CMD next >
OS/2 REXX Batch file  |  1992-07-27  |  3KB  |  90 lines

  1. /* ADDICON.CMD Version 1.1 */
  2. /* by Timothy F. Sipples */
  3. /* July 11, 1992 */
  4.  
  5. /* Modified by Michael J. Strasser to allow multiple filespecs, all */
  6. /* of which can have wildcards. */
  7. /* July 27, 1992 */
  8.  
  9. /* Copyright 1992 by Timothy F. Sipples. */
  10. /* This utility may be freely distributed with all included files. */
  11. /* For-profit (commercial) users: please see the accompanying */
  12. /* documentation for license terms. */
  13.  
  14. /* ADDICON is a REXX utility to attach an icon file to any file */
  15. /* on the system.  It uses the SysSetIcon function in REXX, which */
  16. /* places the icon file in the extended attributes of any given */
  17. /* file. */
  18.  
  19. /* Retrieve command line arguments passed to program. */
  20. /* Also converts to uppercase. */
  21. ARG Arg1 Arg2
  22.  
  23. /* Print title banner. */
  24. SAY ''
  25. SAY 'AddIcon Version 1.1 for OS/2 Version 2.0 and Above'
  26. SAY 'by Timothy F. Sipples (Internet: sip1@ellis.uchicago.edu)'
  27. SAY 'and Michael J. Strasser (Internet: M.Strasser@edn.gu.edu.au)'
  28. SAY ''
  29.  
  30. /* Check for null arguments. */
  31. if Arg1 \= '' & Arg2 \= '' then SIGNAL attach
  32.  
  33. /* If one or both arguments not specified, print usage information. */
  34. SAY 'USAGE:    ADDICON Iconfile Filespec ...'
  35. SAY ''
  36. SAY "Iconfile, an icon file created by OS/2's Icon Editor,"
  37. SAY "will be added to the extended attributes of the specified files."
  38. SAY ''
  39. SAY 'Example:  ADDICON \ICONS\DOC.ICO C:\DATA\TEST.TXT'
  40. SAY ''
  41. SAY 'Wildcards are permitted, as well as multiple filespecs.'
  42. SAY ''
  43. SAY 'Example: ADDICON \ICONS\DOC.ICO C:\DATA\*.TXT C:\WORK\*.TXT'
  44. SAY ''
  45. SAY 'to attach the same icon to all those files.'
  46. SIGNAL end
  47.  
  48. attach:
  49.  
  50. /* Load SysSetIcon function from standard OS/2 REXX library. */
  51. call RxFuncAdd 'SysSetIcon','RexxUtil','SysSetIcon'
  52. /* Ditto for SysFileTree */
  53. CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  54.  
  55. /* Set the error flag */
  56. GotError = 0
  57.  
  58. /* Arg2 is one or more filespecs, which may include wildcard expressions */
  59. DO UNTIL Arg2 = ''
  60.      /* Get the first filespec into Filespec; remainder back into Arg2 */
  61.      PARSE VAR Arg2 Filespec Arg2
  62.      /* Clear the stem variable */
  63.      Files. = ''
  64.      /* Get files & directories, names only */
  65.      call SysFileTree Filespec, 'Files', 'O'
  66.      /* For each filespec, try to attach the icon */
  67.      DO i = 1 TO Files.0
  68.           IF SysSetIcon(Files.i, Arg1) THEN
  69.                SAY 'Icon' Arg1 'successfully attached to file' Files.i'.'
  70.           ELSE DO
  71.                SAY 'ERROR: unable to attach icon' Arg1 'to file' Files.i'.'
  72.                GotError = 1
  73.           END
  74.      END
  75. END
  76.  
  77. IF GotError THEN
  78.      SIGNAL failed
  79.  
  80. end:
  81. SAY ''
  82. EXIT
  83.  
  84. failed:
  85. SAY ''
  86. SAY 'Some errors occurred in attaching icons.'
  87. SAY 'Verify that all files exist, that the icon file is in the'
  88. SAY 'proper format, and that files are not in use by another process.'
  89. SIGNAL end
  90.