home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxlb.zip / SAMPLES / TRAVERSE.CMD < prev    next >
OS/2 REXX Batch file  |  1993-01-08  |  2KB  |  39 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /* Traverse a tree of directories, starting at the current directory,        */
  4. /* issuing a specified command in each directory.                            */
  5. /*                                                                           */
  6. /* Example: traverse erase *.bak                                             */
  7. /*                                                                           */
  8. /* Requires Personal REXX or REXXLIB (doscd, doschdir, dosdir, dosdirpos     */
  9. /* functions).                                                               */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12.  
  13. parse arg command
  14. savecd = doscd()
  15. directory = savecd
  16. if right(directory,1) = '\' then
  17.    directory = left(directory, length(directory) - 1)
  18. call tree directory, command
  19. call doschdir savecd
  20. exit
  21.  
  22. tree: procedure
  23.   parse arg directory, command
  24.   if directory = '' then
  25.      say '--> \'
  26.   else
  27.      say '-->' directory
  28.   call doschdir directory
  29.   command
  30.   name = dosdir(directory'\*.*','n','d','d')
  31.   position = dosdirpos()
  32.   do while name \= ''
  33.     if name \= '.' & name \= '..' then
  34.        call tree directory'\'name, command
  35.     name = dosdir(,'n','d','d',position)
  36.     position = dosdirpos()
  37.    end
  38.   return
  39.