home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / putlong.zip / putlong.cmd
OS/2 REXX Batch file  |  2001-03-07  |  1KB  |  48 lines

  1. /* PutLong.cmd - A little tool to modify or set the .LONGNAME EA */
  2. /* without modifying the real nameof a file.                     */
  3.  
  4. rc = rxFuncAdd('sysLoadFuncs', 'rexxUtil', 'SysLoadFuncs')
  5. if rc \= 0 then call sysLoadFuncs
  6.  
  7. say 'PutLong v1.01 - (C) Cristiano Guadagnino 2001'
  8. say ' '
  9.  
  10. if Arg() = 0 then do
  11.     say 'syntax: PUTLONG <filename> [<longname>]'
  12.     say ' '
  13.     exit
  14. end
  15.  
  16. Parse Arg _filename _longname
  17.  
  18. _retcode = SysGetEA(_filename, '.LONGNAME', 'LONGEA')
  19. if (_retcode = 0) & (LONGEA \= '') then do
  20.     say 'The file ' || _filename || ' already has a .LONGNAME extended'
  21.     say 'attribute, containing: ' || Substr(LONGEA, 5) || '.'
  22.     say 'Do you want to overwrite it? (Y/N) '
  23.     pull _answer .
  24.     if Translate(_answer) \= 'Y' then Exit
  25.     say ' '
  26. end
  27.  
  28. _newEA = 'FDFF'x
  29. if Length(_longname) > 255 then do
  30.     say 'LONGNAME too long.'
  31.     exit
  32. end
  33.  
  34. _newEA = _newEA || D2C(Length(_longname), 1)
  35. _newEA = _newEA || '00'x
  36. _newEA = _newEA || _longname
  37.  
  38. say 'Writing .LONGNAME: "' || _longname || '"...'
  39. _retcode = SysPutEA(_filename, '.LONGNAME', _newEA)
  40.  
  41. if _retcode \= 0 then
  42.     say 'Failed setting .LONGNAME extended attribute.'
  43. else
  44.     say 'Done.'
  45.  
  46. Exit _retcode
  47.  
  48.