[REBOL] Re: Acquiring sub-dir contents
From: ddalley:idirect at: 11-Oct-2001 16:42
Hello, Ryan & Christopher:
Thanks to you both, for your ideas.
On 04-Oct-01, Ryan Cole wrote:
> Does this do what you need?
> get-sub-files: does [
> files: copy []
> foreach item read %. [ if dir? item [append files read item] ]
> ]
Not on its own - I tried it "as is", after getting variable names synced, but
it didn't work. Having said that, I didn't pursue it, to find out >why< it
didn't work for me.
The following is what I ended up using:
; get top drawer-list
drawer-list: READ read-drawer
cur-files: COPY []
all-files: COPY []
; append each directory list into block
FOREACH drawer drawer-list [
new-path: JOIN read-drawer drawer
CHANGE-DIR new-path
cur-files: READ %.
all-files: APPEND all-files cur-files
]
It reads the top drawer, for that drawer's list of directories, builds a new
path for each sub-directory (there's only one sub level), changes its local
path, then reads each sub-directory, appending its file names into a block.
It's not smart, in the sense that it only deals with directories, but it does
what I need, for now. A file in the top drawer will stop the run, though, so
it most definitely can be improved. Making it into a function may be the next
step, but I'll use it this way, for a while, first.
--
---===///||| Donald Dalley |||\\\===---
The World of AmiBroker Support
http://webhome.idirect.com/~ddalley
UIN/ICQ#: 65203020