#!/bin/sh # List directories 0.0.1 , (\) 2008 by Patrick Boylan. # # I, Patrick Boylan, do hereby release this script into the public domain. # There, that looks official. top='dire' # Avoid creating a top-level `index.htm[l]', because # you'll probably want to write that one yourself. dx='index' ht='.htm' ht2='.html' # Using the slightly brain-damaged `.htm' # to avoid filename conflicts. if [ "$1" = "" ] then echo "List what?" exit 1 fi for dire in $@ do if [ ! -d "$dire" ] then echo "\`$dire' is not a directory." exit 1 fi done cred="$(lynx -version | head -n 1)" dtd="$(lynx -dump -source "$1" | head -n 2)" dtd="$dtd\n" # # Give Lynx credit. dtd="$dtd\n" for dire in $@ do ( IFS=' ' cd "$dire" dire="`pwd`" dires="$(find "$dire" -type d)" rm -vf "./$top$ht" # for dir2 in $dires # do rm -vf $(find -type f | grep "/$dx$ht$" -) # done # Remove previously generated files [if any], # so they won't list themselves later. dat="$(lynx -dump -source "$dire/" | tail -n '+3')" echo "$dtd\n$dat" > "$dire/$top$ht" echo "$dire/$top$ht" for dir2 in $dires do if [ "$dir2" != "$dire" ] && [ ! -f "$dir2/$dx$ht2" ] then dat="$(lynx -dump -source "$dir2/" | tail -n '+3')" echo "$dtd\n$dat" > "$dir2/$dx$ht" echo "$dir2/$dx$ht" fi done ) done