Click here to get back home

Command-line program for pretty dir listings needed

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Command-line program for pretty dir listings needed Robert Latest 08-17-2007
Get Chitika Premium
Posted by Robert Latest on August 17, 2007, 9:49 am
Please log in for more thread options


Hello,

if HTML authoring includes HTML autogeneration, this request is on-topic.
Otherwise please forgive me and point me in the right direction.

I'd like to make a bunch of dirs full of files available on a web server. Of
course I could just leave them like they are and have the server take care
of the listings. I don't like that because the listing is entirely
server-dependent, if the server allows dir listings at all. On the server
I'm using the listing is ugly to boot because the server doesn't display
UTF-8 characters correctly; it also doesn't show file sizes and dates.

So what I'm looking for is some little program which, when invoked in a
directory, will produce an index.html file listing the files in that dir,
including date and file size. With a link to the respective file itself of
course.

I could cook up somthing like that myself but I thought, maybe it exists. I
found a couple of PHP scripts that sort of do what I want, but I'd like to
use this method also with local (server-less) file access.

Finally, since I use makefiles to autogenerate my website, the program
should work from the command-line without user intervention. And on Linux.

Suggestions, anyone?

robert

Posted by Jukka K. Korpela on August 17, 2007, 10:38 am
Please log in for more thread options


Scripsit Robert Latest:

> if HTML authoring includes HTML autogeneration, this request is
> on-topic. Otherwise please forgive me and point me in the right
> direction.

It's not about HTML but server-side operations, so c.i.w.a.tools or
c.i.w.a.misc would have been a better choice. This sounds mostly like a
tools question, so I'm sending this to c.i.w.a.tools too and setting
followups there.

> I'd like to make a bunch of dirs full of files available on a web
> server. Of course I could just leave them like they are and have the
> server take care of the listings. I don't like that because the
> listing is entirely server-dependent, if the server allows dir
> listings at all.

That's true, but the situation is server-dependent anyway (unless you do
preprocessing: generate the listing yourself and upload it whenever you make
a change to the collection of files). If you use, say, PHP to generate the
listing, then you would have to change something if you move the site to a
system where PHP is not allowed.

> On the server I'm using the listing is ugly to boot
> because the server doesn't display UTF-8 characters correctly; it
> also doesn't show file sizes and dates.

Well, that's a good enough reason to something about it. However, it's not
certain that existing software for your purposes will do UTF-8 either.

> So what I'm looking for is some little program which, when invoked in
> a directory, will produce an index.html file listing the files in
> that dir, including date and file size. With a link to the respective
> file itself of course.

You get more challenges (and, if successful, better results) if you use
short codes or icons that indicate the type of each file (like DOC, GIF
etc.), if there are different types.

> Finally, since I use makefiles to autogenerate my website, the program
> should work from the command-line without user intervention. And on
> Linux.

Oh, then you're doing preprocessing, and you have different options. I'm
pretty sure there are utilities for your purposes, but writing a suitable
one might be easier than finding a suitable one. :-) Sounds like a job for
Perl.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Posted by Andreas Prilop on August 17, 2007, 11:15 am
Please log in for more thread options


On Fri, 17 Aug 2007, Robert Latest wrote:

> I'd like to make a bunch of dirs full of files available on a web server.

Address (URL)? Which server software?

> I'm using the listing is ugly to boot because the server doesn't display
> UTF-8 characters correctly;

You must use "percent encoding" by RFC 3986.
http://www.unics.uni-hannover.de/nhtcapri/%25/

> So what I'm looking for is some little program which, when invoked in a
> directory, will produce an index.html file listing the files in that dir,
> including date and file size. With a link to the respective file itself of
> course.

Apache can do this for you.
http://httpd.apache.org/docs/1.3/mod/mod_autoindex.html

Posted by David E. Ross on August 17, 2007, 12:54 pm
Please log in for more thread options


On 8/17/2007 6:49 AM, Robert Latest wrote:
> Hello,
>
> if HTML authoring includes HTML autogeneration, this request is on-topic.
> Otherwise please forgive me and point me in the right direction.
>
> I'd like to make a bunch of dirs full of files available on a web server. Of
> course I could just leave them like they are and have the server take care
> of the listings. I don't like that because the listing is entirely
> server-dependent, if the server allows dir listings at all. On the server
> I'm using the listing is ugly to boot because the server doesn't display
> UTF-8 characters correctly; it also doesn't show file sizes and dates.
>
> So what I'm looking for is some little program which, when invoked in a
> directory, will produce an index.html file listing the files in that dir,
> including date and file size. With a link to the respective file itself of
> course.
>
> I could cook up somthing like that myself but I thought, maybe it exists. I
> found a couple of PHP scripts that sort of do what I want, but I'd like to
> use this method also with local (server-less) file access.
>
> Finally, since I use makefiles to autogenerate my website, the program
> should work from the command-line without user intervention. And on Linux.
>
> Suggestions, anyone?
>
> robert

Go to my home page (per my signature below). Scroll to the bottom.
Select "Index of HTML Files". Is this something similar to what you want?

--
David E. Ross
<http://www.rossde.com/>

Natural foods can be harmful: Look at all the
people who die of natural causes.

Posted by Michael Stemper on August 17, 2007, 1:24 pm
Please log in for more thread options



>I'd like to make a bunch of dirs full of files available on a web server. Of
>course I could just leave them like they are and have the server take care
>of the listings.

>So what I'm looking for is some little program which, when invoked in a
>directory, will produce an index.html file listing the files in that dir,
>including date and file size. With a link to the respective file itself of
>course.

The following doesn't do size or date, but that should be a minor tweak.
Also, if the file contains a meta description, that'll be used for the
link text in place of the file name. Easy enough to undo if you always
want file names.

----------------------------------------------------
#!/bin/ksh
# Index generator
# Michael F. Stemper 16 May 2002
#
# Descriptive link generated only from files that contain a line with
# the following format:
# <meta name="description" content="This is the link text">
# Other files will just have their file name (less suffix) as link text
# Multiple meta descriptions (after the first) will ignored. I'm not sure
# what will happen if your meta description crosses multiple lines.
#
# Known bug: It includes itself, but I'm too lazy to deal with this.

TempFile=/tmp/index.$$

cat > $TempFile << HEADER
<html>
<head>
<title>Directory listing</title>
</head>
<body>
<h1>Directory Listing</h1>
<ul>
HEADER

for f in `ls *.shtml *.html *.htm 2>/dev/null`
do
DescLine=`grep -h 'meta name="description"' $f | head -1`
Description=`echo $DescLine | sed 's/.*name="description" *//' | cut -f2 -d\"`
if [[ $Description = "" ]]
then
Description=`echo $f | sed 's/\.htm.*//'`
fi
echo " <li><a href=$f>$Description</a></li>" >> $TempFile
done

cat >> $TempFile << FOOTER
</ul>
</body>
</html>
FOOTER

mv $TempFile ./index.html
chmod 644 ./index.html
----------------------------------------------------

--
Michael F. Stemper
#include <Standard_Disclaimer>
This message contains at least 95% recycled bytes.


Similar ThreadsPosted
Commandline RTF to HTML converter February 1, 2005, 4:19 pm
a commandline tool to drop css and javascript? January 27, 2007, 11:22 pm
Search over 500,000+ fresh job listings posted within last 3 weeks August 3, 2005, 4:15 pm
css program February 16, 2005, 10:57 pm
New Sitemap Program June 20, 2005, 8:47 am
How do I call a program August 18, 2005, 11:12 pm
Which web design program to use May 15, 2007, 3:55 pm
Looking for a good FTP program February 16, 2008, 9:14 am
Embedding a URL as an argument to a CGI program January 14, 2005, 7:57 pm
New Affiliate program 80% Commission April 14, 2005, 1:23 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap