Task

Walk a given directory tree and print files matching a given pattern.


Note: This task is for recursive methods.   These tasks should read an entire directory tree, not a single directory.


Note: Please be careful when running any code examples found here.



Related task

   Walk a directory/Non-recursively   (read a single directory). 


      directory$ = "C:\Windows\"
      pattern$ = "*.chm"
      PROClisttree(directory$, pattern$)
      END
 
      DEF PROClisttree(dir$, filter$)
      LOCAL dir%, sh%, res%
      DIM dir% LOCAL 317
      IF RIGHT$(dir$) <> "\" IF RIGHT$(dir$) <> "/" dir$ += "\"
      SYS "FindFirstFile", dir$ + filter$, dir% TO sh%
      IF sh% <> -1 THEN
        REPEAT
          IF (!dir% AND 16) = 0 PRINT dir$ + $$(dir%+44)
          SYS "FindNextFile", sh%, dir% TO res%
        UNTIL res% = 0
        SYS "FindClose", sh%
      ENDIF
      SYS "FindFirstFile", dir$ + "*", dir% TO sh%
      IF sh% <> -1 THEN
        REPEAT
          IF (!dir% AND 16) IF dir%?44 <> &2E THEN
            PROClisttree(dir$ + $$(dir%+44) + "\", filter$)
          ENDIF
          SYS "FindNextFile", sh%, dir% TO res%
        UNTIL res% = 0
        SYS "FindClose", sh%
      ENDIF
      ENDPROC