home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / subject.cmd < prev    next >
OS/2 REXX Batch file  |  1996-04-10  |  3KB  |  109 lines

  1. /*******************************************************************
  2.    Displays or sets the subject (comment) of one or more files or
  3.    folders
  4.  
  5.    Place this file as Subject.cmd somewhere in your path.
  6.  
  7.    Examples:
  8.    Set subject on one file:
  9.      Subject shoplist.txt This is my shopping list
  10.  
  11.    Display the subject on all files in current directory
  12.      Subject *
  13.  
  14.    Display the subject on all files in current directory and below
  15.      Subject * /S
  16.  
  17.    Delete the subject of a file:
  18.      Subject myfile.txt /D
  19.  
  20.    Delete the subject of all files in current folder and below
  21.      Subject * /DS
  22.  
  23.    Deletion means actually only truncating the subject field to zero i.e. the
  24.    extended attribute '.SUBJECT' still exists, but contains no data. 13 bytes
  25.    of extended attributes will remain allocated. If you want to remove these
  26.    bytes, you must at first set a subject and then delete it manually through the
  27.    settings menu item.
  28.  
  29.   Jorgen Thomsen, Feb. 22, 1996
  30.   71310.2206@compuserve.com
  31.   (with improvements by Rob Goodman)
  32.  *******************************************************************/
  33.  
  34. Parse Arg fil opt Subject
  35. opti = translate(opt)
  36. options = ''
  37. if opti = "/S" | opti = "/DS" then options = "S"
  38. else
  39.   Subject = opt||' '||Subject
  40. if left(opti,2) = '/D' then
  41.   do
  42.     opti = '/D'
  43.     Subject = ''
  44.   end
  45.  
  46. if fil = "" then
  47. do
  48.   say " Displays or sets the subject (comment) of one or more files or"
  49.   say " folders"
  50.   say ""
  51.   say " Place this file as Subject.cmd somewhere in your path."
  52.   say ""
  53.   say " Examples:"
  54.   say " Set subject on one file:"
  55.   say "   Subject shoplist.txt This is my shopping list"
  56.   say ""
  57.   say " Display the subject on all files in current directory"
  58.   say "   Subject *"
  59.   say ""
  60.   say " Display the subject on all files in current directory and below"
  61.   say "   Subject * /S"
  62.   say ""
  63.   say " Delete the subject of a file:"
  64.   say "   Subject myfile.txt /D"
  65.   say ""
  66.   say " Delete the subject of all files in current folder and below"
  67.   say "   Subject * /DS"
  68.   say ""
  69.   say " Deletion means actually only truncating the subject field to zero i.e. the"
  70.   say " extended attribute '.SUBJECT' still exists, but contains no data. 13 bytes"
  71.   say " of extended attributes will remain allocated. If you want to remove these"
  72.   say " bytes, you must at first set a subject and then delete it manually through the"
  73.   say " settings menu item."
  74.   say ""
  75.   exit
  76. end
  77.  
  78. if RxFuncQuery('SysLoadFuncs') THEN
  79. do
  80.   /*-- load the load-function --*/
  81.   CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  82.   /*-- load the Sys* utilities --*/
  83.   CALL SysLoadFuncs
  84. end
  85.  
  86. rc = SysFileTree(fil, res, options||"OB")
  87.  
  88. do i=1 to res.0
  89.   fil = res.i
  90.   If (Subject <> '') | (opti = '/D') then do
  91.     if opti = '/D' then do
  92.       SUBJECTINFO = ''
  93.       rc = SysGetEA(fil, ".SUBJECT", "SUBJECTINFO")
  94.       parse var SUBJECTINFO 5 Subj
  95.       if (SUBJECTINFO = '') | (Subj = '') then iterate i
  96.       say res.i||': subject deleted'
  97.     end
  98.  
  99.     result = SysPutEA(fil, ".SUBJECT", 'FDFF'x||d2c(Length(subject))||'00'x||Subject)
  100.   end
  101.  
  102.   if SysGetEA(fil, ".SUBJECT", "SUBJECTINFO") = 0 then do
  103.      parse var SUBJECTINFO 5 Subj
  104.      If Subj <> '' then do
  105.        say fil ":" Subj
  106.      end
  107.   end
  108. end
  109.