Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for fileattr.rex

(view source code of fileattr.rex as plain text)

  1. /* FileAttr,  Version 2.01                  */
  2. /* Cloned from the Norton Utilities for DOS */
  3. /* Display files with specified attributes, */
  4. /* and/or set the specified attributes      */
  5. /* Written by Rob van der Woude             */
  6. /* http://www.robvanderwoude.com            */
  7.  
  8. /* Initialize RexxUtil */
  9. If RxFuncQuery( "sysloadfuncs" ) <> 0 Then Do
  10. 	Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"
  11. 	Call sysloadfuncs
  12. End
  13.  
  14. /* Command line parsing */
  15. Parse Upper Arg files parameters
  16. If files = "/?" Then Call Syntax
  17. If files = "" Then files = "*"
  18. Alist = "*"
  19. Hlist = "*"
  20. Rlist = "*"
  21. Slist = "*"
  22. Aset  = "*"
  23. Hset  = "*"
  24. Rset  = "*"
  25. Sset  = "*"
  26. If Pos( "+", parameters ) > 0 Then Do
  27. 	If Pos( "A+", parameters ) > 0 Then Aset  = "+"
  28. 	If Pos( "H+", parameters ) > 0 Then Hset  = "+"
  29. 	If Pos( "R+", parameters ) > 0 Then Rset  = "+"
  30. 	If Pos( "S+", parameters ) > 0 Then Sset  = "+"
  31. 	If Pos( "+A", parameters ) > 0 Then Alist = "+"
  32. 	If Pos( "+H", parameters ) > 0 Then Hlist = "+"
  33. 	If Pos( "+R", parameters ) > 0 Then Rlist = "+"
  34. 	If Pos( "+S", parameters ) > 0 Then Slist = "+"
  35. End
  36. If Pos( "-", parameters ) > 0 Then Do
  37. 	If Pos( "A-", parameters ) > 0 Then Aset  = "-"
  38. 	If Pos( "H-", parameters ) > 0 Then Hset  = "-"
  39. 	If Pos( "R-", parameters ) > 0 Then Rset  = "-"
  40. 	If Pos( "S-", parameters ) > 0 Then Sset  = "-"
  41. 	If Pos( "-A", parameters ) > 0 Then Alist = "-"
  42. 	If Pos( "-H", parameters ) > 0 Then Hlist = "-"
  43. 	If Pos( "-R", parameters ) > 0 Then Rlist = "-"
  44. 	If Pos( "-S", parameters ) > 0 Then Slist = "-"
  45. End
  46. If Pos( "*", parameters ) > 0 Then Do
  47. 	If Pos( "A*", parameters ) > 0 Then Aset  = "*"
  48. 	If Pos( "H*", parameters ) > 0 Then Hset  = "*"
  49. 	If Pos( "R*", parameters ) > 0 Then Rset  = "*"
  50. 	If Pos( "S*", parameters ) > 0 Then Sset  = "*"
  51. 	If Pos( "*A", parameters ) > 0 Then Alist = "*"
  52. 	If Pos( "*H", parameters ) > 0 Then Hlist = "*"
  53. 	If Pos( "*R", parameters ) > 0 Then Rlist = "*"
  54. 	If Pos( "*S", parameters ) > 0 Then Slist = "*"
  55. End
  56.  
  57. options = "F"
  58. If Pos( "/S", parameters ) > 0 Then options = options||"S"
  59. listattr = Alist||"*"||Hlist||Rlist||Slist
  60. setattr  = Aset||"*"||Hset||Rset||Sset
  61.  
  62. Call SysFileTree files, "file.", options, listattr, setattr
  63. If file.0 > 0 Then Do i = 1 to file.0
  64. 	Say SubStr( file.i, 30 )
  65. End
  66.  
  67. /* End main program */
  68. Exit 0
  69.  
  70.  
  71. Syntax:
  72. 	Say
  73. 	Say "FileAttr,  Version 2.01"
  74. 	Say "Inspired by the Norton Utilities for DOS."
  75. 	Say "Display and/or change file attributes of specified files."
  76. 	Say
  77. 	Say "Usage:    FILEATTR.REX  filespec  [ options ]"
  78. 	Say
  79. 	Say 'Options:  format is "dAs":'
  80. 	Say "                    d (display) is either *, - or +"
  81. 	Say "                    A (attribute) can be A, H, R or S"
  82. 	Say "                    s (set) is either *, - or +"
  83. 	Say "          /S        include subdirectories"
  84. 	Say
  85. 	Say "Examples: *R+       make all files Read-only (set R attribute)."
  86. 	Say "          -H+       show files that are not hidden and make them hidden."
  87. 	Say "          -A* *S+   set S (system) attribute of all files that have their A"
  88. 	Say "                    (archive) attribute not set."
  89. 	Say
  90. 	Say "Note:     In Windows, RegUtil's SysFileTree does not (yet) set file attributes,"
  91. 	Say '          hence the "set" option ("s" in "dAs") is ignored in Windows.'
  92. 	Say
  93. 	Say "Written by Rob van der Woude"
  94. 	Say "http://www.robvanderwoude.com"
  95. 	Exit 255
  96. Return
  97.  

page last uploaded: 2017-08-21, 14:26