home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 375.lha / dirprint.rexx < prev    next >
OS/2 REXX Batch file  |  1990-05-02  |  2KB  |  97 lines

  1. /* Directory Lister
  2.     This REXX script will list all of the files in 
  3.     a directory from where you are to the deepest
  4.         subdirectory. I wrote it primarily to give me a
  5.         tool by which I get a     directory HC to store with
  6.         each disk. The only arguments that the program takes is 
  7.  
  8.     FILENAME The filename to which the output should be sent
  9.            defaults to printing to the console (Say command)
  10.  
  11.     Author Michael E. Stamps
  12.     Program Type: FreeBie Ware
  13.     Blame: The author accepts no responsibilty for anything
  14.              this program does. He also does not accept responsiblity
  15.            for the depletion of the ozone layer and a multitude of
  16.                other things.
  17.         Documentation: This is it.
  18. */
  19.  
  20. arg FILENAME
  21.  
  22. null = addlib('rexxsupport.library',0,-30,0) 
  23. null = addlib('rexxmathlib.library',0,-30,0) 
  24. null = addlib('rexxarplib.library',0,-30,0)   
  25.  
  26. If FILENAME ~= "" Then
  27.   do
  28.   check = open("output",Filename,"write")
  29.   If check ~= 1 Then
  30.     Do
  31.     Say Filename' Cannot be opened for output'
  32.     Exit
  33.     End
  34.   EndIf
  35.   end
  36. EndIf
  37.  
  38. If FileName = "" Then
  39.   null = WriteDirs1(0)
  40. Else
  41.   null = WriteDirs2(0)
  42. exit /* end of program */
  43.  
  44. /*===============================================================*/
  45. WriteDirs1: Procedure Expose MAXLEVELS
  46. arg Depth
  47.  
  48. spacer = copies("  ",depth)
  49. numdirs  = FileList("*" , Dirs  ,"D")
  50. numfiles = FileList("*" , Files ,"F")
  51.  
  52. CurrDirectory = 
  53.  
  54. do i = 1 to numfiles
  55.   Say spacer''files.i
  56. end
  57.  
  58. if numdirs > 0 Then
  59.   do i = 1 to numdirs
  60.     say ""
  61.     say spacer'<'Dirs.i'>'
  62.     null = Pragma('Directory',dirs.i)
  63.     null = WriteDirs1(Depth + 1) 
  64.     null = Pragma('Directory','/') 
  65.   end /* i */
  66.  
  67. return Files.
  68.  
  69. /* ================================================================= */
  70.  
  71.  
  72. WriteDirs2: Procedure Expose MAXLEVELS
  73. arg Depth
  74.  
  75. spacer = copies("  ",depth)
  76. numdirs  = FileList("*" , Dirs  ,"D")
  77. numfiles = FileList("*" , Files ,"F")
  78.  
  79. CurrDirectory = 
  80.  
  81. do i = 1 to numfiles
  82.   null = writeln("output",spacer''files.i)
  83. end
  84.  
  85. if numdirs > 0 Then
  86.   do i = 1 to numdirs
  87.     null = writeln("output","")
  88.     null = writeln("output",spacer'<'Dirs.i'>')
  89.     null = Pragma('Directory',dirs.i)
  90.     null = WriteDirs2(Depth + 1) 
  91.     null = Pragma('Directory','/') 
  92.   end /* i */
  93.  
  94. return Files.
  95.  
  96. /* ================================================================= */
  97.