[REBOL] Re: Filtering files in directories.
From: chris:ross-gill at: 2-Jan-2003 14:42
Ok, this is neither pattern matching (works by suffix) nor does it bypass
the need to load a full list of files (not sure there's any other way to do
it), but it can be hacked relatively easily for your own needs.
>> read-filter %./ %.jpg
>> read-filter %./ [%.html %.r]
It also retains directories, but that could be dropped from the source.
read-filter: func [
loc [file! url!] "Path to Read"
sfx [file! block!] "Suffix to Search For"
return either exists? loc: dirize loc [
files: read loc
remove-each file files [
not any [ ; Conditions to retain files
dir? join loc file
sfx = suffix? file
find sfx suffix? file