[REBOL] Re: recursive directory copying...
From: greggirwin:mindspring at: 12-May-2003 16:34
Hi Tom,
t6c> I was just wondering if anyone has written a recursive directory copying
t6c> script. I found %dir-mapper.r, but that just recreates the structure without
t6c> copying. I'd like to do:
You could start off with something like this to get a list of files. It
isn't efficient, but it's short and easy.
all-files: func [
{Returns a block of fully qualified filenames for the directory.}
spec [file!] "Starting Directory"
block [block!] "Block to append to"
/deep "Recurse sub-directories."
/local f-spec
][
spec: dirize spec
foreach file read spec [
f-spec: join spec file
either all [deep dir? f-spec] [
wait 0
all-files/deep f-spec block
][
if not dir? file [append block f-spec]
]
]
block
]
Now, just iterate over that list, apply constraints to what you want
to copy, change the path for your target file (change/part,
split-path, etc.), and use write/binary+read/binary to copy it.
-- Gregg