Page 1 of 1

recursive stuff

Posted: Sat Sep 25, 2004 8:18 pm
by tom
Hi guys,

Sorry, I'm a bonehead. I want to perform an action on all the files
in a directory, in any subdirectories, and any sub-subdirecories.

I can use a combo of (directory "dir") and (directory? "dir"), right?

lisp, scheme, newlisp, they all evaluate from the inside out, right?
the innermost parentheses first, then out?

I may "get it" one day...

Thanks for your patience :-)

Posted: Sun Sep 26, 2004 12:40 am
by Lutz
try this:

Code: Select all

(define (show-tree dir)
  (dolist (nde (directory dir))
    (if (and (directory? (append dir "/" nde)) (!= nde ".") (!= nde ".."))
          (show-tree (append dir "/" nde))
          (println (append dir "/" nde)))))

(show-tree "/usr")    ; on Linux/UNIX

(show-tree "/")

(show-tree "c:\\") ;; works ~ on Win32

(show-tree "c:/") ;; also works on Win32

Lutz