[Off Topic] Directory Listing to HTML
Styma, Robert E (Robert)
stymar at alcatel-lucent.com
Wed Sep 19 17:07:39 UTC 2007
>
> Anyone have a good script to generate an HTML file for a directory
> listing?
>
I use this to generate an index.html for the cartoons I have
in a directory. It works in the current directory and generates
an index.html file with links to all the other files.
---------------------- start ------------------------------
#!/bin/bash
#set -xv
dir=`/bin/pwd`
if [ -f index.html ]
then
echo "remove index.html from directory $dir manually"
exit 1
fi
dir=`basename $dir`
tmpfile=/tmp/bi$$
find . -type f -print | sed -e 's!^\./!!' -e 's! !%20!g' | sort >
$tmpfile
echo "<html>" > index.html
echo "<head>" >> index.html
echo "<title>$dir</title>" >> index.html
echo "<META NAME="GENERATOR" CONTENT="build_index.html.sh">" >>
index.html
echo "</head>" >> index.html
echo "<body>" >> index.html
echo "<h1>$dir</h1>" >> index.html
for i in `cat $tmpfile`
do
j=`echo "$i" | sed -e 's!%20! !g'`
echo "<br><a href=\"$i\">$j</a>" >> index.html
done
rm $tmpfile
echo "</body>" >> index.html
echo "</html>" >> index.html
------------------------end ------------------------------
Bob S
Phoenix, AZ
More information about the fedora-list
mailing list