#!/bin/sh
# ~jhs/public_html/bin/.sh/html2lmth
# This script can be manually invoked in directories that have a mixed 
# collection of some .html & some .lmth.
# it moves those .html that do not have an owning .lmth to become a .lmth.
# The meaning of a .lmth file is documented (well, at least, 
# defined how it is used) in <berklix.mk>

for i in *.html ; do
	x=`basename $i .html`
	# echo $x
	if [ \! -e $x.lmth ]; then 
		# Target doesnt exist so maybe move it.
		if [ \! -L $x.html ]; then
		# -f does not work as I want. 
		# "man test" says it gets dereferenced.
			# echo "Moving: $x.html"
			# ls -l $x.html
			mv $x.html $x.lmth ;  # ls -l $x.lmth
		else    # Source is not a file, prob a symbolic link,
			# echo 	"Skipping: $x.html" 
			ls -l $x.html
			# echo	" as it is a symbolic link."
			fi
	else	# Target $x.lmth exists. Dont over write it.
		# echo 	"Skipping: $x.html"
		# echo	" as target exists: $x.lmth" # 
		# ls -l $x.*
	fi
	done
echo "Suggestion: make html"
	

