Hi, I'm need an HTML listing of all files in a given directory tree (not
necessarily starting at the root level).
Here's some preliminary code I've written so far while I've been doing other
work:
starting_directory: %/c/
filelist: []
getlistoffiles: func [dir][
dirlist: read dir
foreach item dirlist [
either not dir? item [
append filelist rejoin [dir item]
][
getlistoffiles item
]
]
]
getlistoffiles starting_directory
print ["<html><head><title>Every file in " starting_directory
"</title></head><body>"]
foreach file filelist [
print rejoin ["<a href=^"file://" file "^">" file "</a>"]
]
print "</body></html>"
---------------------------
Once it's working I'm going to write the whole thing I'm just printing to
the console now to a file of course.
Seems like it should be really simple, but I'm running into some problems.
For some reason it isn't "recursing" and getting the subdirectories, and
even though I have the "dir?" test in there it's still putting directories
in 'filelist. Also, since I'm on Windows, the "file" that I get from the
foreach at the bottom isn't good enough to put as an HTML link since it
doesn't have the colon in it. i.e. It looks like "file:///c/blahblah"
rather than "file:///c:/blahblah"
If anyone could lend any assistance I'd be grateful. And of course if
someone's already written a script to do exactly this, if anyone could point
me to it it'd be great. Thanks!
Keith