Code: Select all
#!/bin/sh
# Version=0.0.4
# drag N drop html index maker
# "$@" is a directory to index as html
# technosaurus author
# big_bass improved generated source code readability
# abushcrafter: Improved output HTML.
# abushcrafter: Fixed delete existing "index.html".
# abushcrafter: Added size and modified date code by big_bass.
cd "$@"
#---------------------
# clean up old debugging files
#---------------------
rm -f "$@"/index.html
rm -f /tmp/flist2
rm -f /tmp/dlist2
#---------------------
# generate the directory and file index
#---------------------
for x in *
do [ -d "$x" ] && echo " <li><a href=\"$x/\">$x/</a></li>" >> /tmp/dlist2
! [ -d "$x" ] && echo " <li><a href=\"$x\">$x</a> ,`ls -lh \"$x\" | awk '{ print $5 }'`KB, Date Modified=`ls -lh \"$x\" | awk '{ print $6 }'`</li>" >>/tmp/flist2
done
#---------------------
# Head make the html head
#---------------------
echo "<html>
<head>
<title>Index Of: "$@"</title>
</head>
<body>
<h1>Index Of "$@"</h1>
<h2>Directories:</h2>
<ul>
<li><strong><a href=\"../\">[Parent Directory]</a></strong></li>">"$@"/index.html
#---------------------
# Body append the dynamic info for the index here the (directories )
#---------------------
cat /tmp/dlist2>>"$@"/index.html
echo " </ul>">>"$@"/index.html
#---------------------
# Body append the dynamic info for the index here the (files )
#---------------------
echo " <h2>Files:</h2>
<ul>" >>"$@"/index.html
cat /tmp/flist2 >>"$@"/index.html
echo " </ul>" >>"$@"/index.html
#---------------------
#Close the html header
#---------------------
echo " </body>
</html>" >>"$@"/index.html
# remove new debugging files
#rm -f /tmp/flist2
#rm -f /tmp/dlist2