home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / fm2_214.zip / SDIR.CMD < prev    next >
OS/2 REXX Batch file  |  1994-08-08  |  2KB  |  75 lines

  1. /*
  2.  * show a directory including .SUBJECT EAs
  3.  * SDIR /? for help.
  4.  */
  5.  
  6. '@echo off'
  7. parse arg mask recurse
  8. mask = strip(mask)
  9. if mask = '/?' then
  10. do
  11.   say 'SDIR is a DIR-like command that shows .SUBJECT EAs in its display.'
  12.   say ''
  13.   say 'Usage: SDIR mask /s'
  14.   say ''
  15.   say ' Both mask and /s are optional.  mask filters the files/directories shown'
  16.   say ' and may contain wildcard characters ? and *.  /s is a switch meaning to'
  17.   say ' recurse into subdirectories, and cannot be used if mask contains spaces'
  18.   say ' (in which case mask should be surrounded with quotes).  If you use /s,'
  19.   say ' you must also give mask.  Order of parameters is enforced.'
  20.   say ''
  21.   say 'Examples:  SDIR *.exe'
  22.   say '           SDIR d:\*.zip /s'
  23.   say '           SDIR 'd2c(34)'long filename number *'d2c(34)
  24.   exit
  25. end
  26. if left(mask,1) = d2c(34) then
  27. do
  28.   recurse = ''
  29.   parse arg mask
  30.   mask = substr(mask,2)
  31.   if right(mask,1) = d2c(34) then
  32.     mask = left(mask,length(mask) - 1)
  33. end
  34. if mask = '' then
  35.   mask = '*'
  36. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  37. call SysLoadFuncs
  38. recurse = translate(recurse)
  39. if recurse = '/S' then
  40.   rc = SysFileTree(mask,filename,'S')
  41. else
  42. do
  43.   recurse = ''
  44.   rc = SysFileTree(mask,filename)
  45. end
  46. if rc = 0 then
  47. do
  48.   do i=1 to filename.0
  49.     parse var filename.i fdate ftime fsize fattr fname
  50.     filename.i = left(filename.i,length(filename.i) - length(fname))
  51.     fname = strip(fname)
  52.     if recurse = '' then
  53.     do
  54.       lpos = lastpos('\',fname)
  55.       if lpos \= 0 then
  56.         rname = substr(fname,lpos + 1)
  57.       else
  58.         rname = fname
  59.     end
  60.     else
  61.       rname = fname
  62.     say filename.i'  'rname
  63.     if SysGetEA(fname,'.SUBJECT','text') = 0 then
  64.     do
  65.       text = substr(text,5)
  66.       text = strip(text)
  67.       if text \= '' then
  68.         say '  +'text
  69.     end
  70.   end
  71. end
  72. else
  73.   say 'Out of memory.'
  74. exit
  75.