home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: WPS_PM / WPS_PM.zip / inf2icon.zip / INF2ICON.CMD next >
OS/2 REXX Batch file  |  1998-11-15  |  2KB  |  75 lines

  1. /* INF2ICON.CMD - makes icons from INF files
  2. */
  3.  
  4. parse arg filespec folder
  5. if filespec = '' then do
  6.    say 'Usage:'
  7.    say 'INF2ICON inf_file [folder_name]'
  8.    say ''
  9.    say 'inf_file is the name of the INF file for which you want an icon'
  10.    say 'folder_name is the a folder on the desktop where you want the ICONS to go'
  11.    exit
  12. end
  13.  
  14. if folder = '' then do
  15.    folder = 'Online Help'
  16. end
  17.  
  18. /* objectid = translate(folder, , '!@#$%^&*()_-_=+[]{};:"/?.>,<`~ ')
  19. */
  20. objectid = '<'translate(folder, '_', ' ')'>'
  21. objectid = translate(objectid)
  22. say folder
  23. say objectid
  24.  
  25. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  26. Call SysLoadFuncs
  27.  
  28. call SysFileTree filespec, 'files', 'FO', '*-***'
  29. say 'Folder name:' folder
  30. call SysCreateObject "WPFolder", folder, "<WP_DESKTOP>", 'OBJECTID='objectid, 'U'
  31.  
  32. do i = 1 to files.0
  33.    filespec = translate(files.i)
  34.    if right(filespec,4) == '.INF' then do
  35.       say 'File:' filespec
  36.       x = 0
  37.       do forever
  38.          c = charin(filespec, x + 108, 1)
  39.          if c2d(c) = 0 then leave
  40.          x = x + 1
  41.       end
  42.       title = charin(filespec, 108, x)
  43.       dot = lastpos(".",filespec)
  44.       slash = lastpos("\",filespec)
  45.       filename = substr(filespec, slash + 1, 255)
  46.       pathname = left(filespec, slash)
  47.       basename = substr(filespec, slash + 1, dot - slash - 1)
  48.  
  49.       say 'Filename:' filename
  50.       say 'Basename:' basename
  51.       say 'Pathname:' pathname
  52.       number = right(basename,1)
  53.       if number >= '0' & number <= '9' then do
  54.          say 'Number:' number
  55.          call SysCreateObject "WPProgram", title, objectid, 'EXENAME=VIEW.EXE;STARTUPDIR='||pathname||';PARAMETERS='||basename, 'U'
  56.       end
  57.       call SysCreateObject "WPProgram", title, objectid, 'EXENAME=VIEW.EXE;STARTUPDIR='||pathname||';PARAMETERS='||basename, 'U'
  58.    end
  59. end
  60. exit
  61.  
  62. title: procedure
  63.    arg filespec
  64.       say 'File:' filespec
  65.       x = 0
  66.       do forever
  67.          c = charin(filespec, x + 108, 1)
  68.          if c2d(c) = 0 then leave
  69.          x = x + 1
  70.       end
  71.       if x = 0 then
  72.          return 'Untitled'
  73.       else
  74.          return charin(filespec, 108, x)
  75.