Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] make-pool

From: fantam::mailandnews::com at: 30-Apr-2001 16:45

Hello all, The following is one of my favorite swiss-knife function, so I thought I'd share it on this list. It is used to build blocks of files given a directory, with or without filter. Here it goes: REBOL [ Title: "mezzanine function" Description: "Find files under a given directory" Date: 18/3/2001 Author: "fantam" email: [fantam--mailandnews--com] usage: { make-pool %/d/docs/ or, with filter: make-pool/filter %"/d/web sites/rebol/" "htm gif jpg" } ] make-pool: func [root-folder [file!] /filter extension [string!] /verbose "prints message" /local files ] [ files: copy [] if found? filter [ extension: parse extension none if not (length? extension) = 1 [ extension: next extension while [not tail? extension] [insert extension to-word "|" extension: next next extension] extension: head extension ] ] recursive: func [dir [file!] /local ext] [ foreach file read dir [ either not dir? dir/:file [ either found? filter [ if not none? ext: find/last file "." [ if parse next ext extension [append files dir/:file] ] ] [ append files dir/:file ] ] [recursive dir/:file] ] ] either dir? root-folder [ recursive dirize root-folder ] [ print [mold root-folder "no valid folder"] ] if verbose [print reduce [length? files "files in pool."]] files ]