recursive stuff

Q&A's, tips, howto's
Locked
tom
Posts: 168
Joined: Wed Jul 14, 2004 10:32 pm

recursive stuff

Post 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 :-)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

Locked