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). 


(use posix)
(use files)
(use srfi-13)
 
(define (walk FN PATH)
  (for-each (lambda (ENTRY) 
    (cond ((not (null? ENTRY))
 
	   (let ((MYPATH (make-pathname PATH ENTRY)))
 
	     (cond ((directory-exists? MYPATH)
		    (walk FN MYPATH) ))
 
	     (FN MYPATH) )))) (directory PATH #t) ))
 
(walk (lambda (X) (cond ((string-suffix? ".scm" X) (display X)(newline) ))) "/home/user/")