RE: [Off Topic] Directory Listing to HTML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 >  
> 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


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux