Date: Thu, 9 Oct 1997 11:10:29 +0200 (MET DST) From: Wolfram Schneider <wosch@cs.tu-berlin.de> To: docs@freebsd.org Subject: html file names Message-ID: <199710090910.LAA00672@panke.panke.de>
next in thread | raw e-mail | index | archive | help
$ cvs co FAQ
$ cd FAQ
$ make FORMATS=html
generate file names like FAQ[0-9]*.html
FAQ1.html FAQ10.html FAQ100.html FAQ101.html FAQ102.html
FAQ103.html FAQ104.html FAQ105.html FAQ106.html FAQ107.html
FAQ108.html [...]
the script rename the file names to FAQ<title>.html
e.g.:
$ <script> FAQ
$ ls
FAQ_ACKNOWLEDGMENTS.html
FAQ_Any_restrictions_on_how_I_divide_the_disk_up_.html
FAQ_Are_there_any_Database_systems_for_FreeBSD_.html
FAQ_Are_there_any_commercial_high-performance_X_servers_.html
FAQ_Books_on_FreeBSD.html
FAQ_Can_FreeBSD_handle_multiport_serial_cards_sharing_irqs_.html
FAQ_Can_I_connect_my_Win95_box_to_the_Internet_via_FreeBSD_.html
FAQ_Can_I_follow_current_with_limited_Internet_access_.html
FAQ_Can_I_install_on_a_disk_with_bad_blocks_.html
[...]
#!/bin/sh
#
# Copyright (c) 1997 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
# All rights reserved.
#
# rename sgml/html generated file names to human readable file names
#
# $Id$
case $# in 0)
echo "usage `basename $0` file"
exit 1
esac
file=$1; export file
if [ -f "$file.html" ]; then :
else
echo "$file.html does not exist"
exit 1
fi
# search for title name
egrep -i '^<title' $file[1-9]*.html |
perl -npe 's/<TITLE>[\*\s]*//; s%\s*</TITLE>.*%%;
s/[^a-zA-Z0-9\_\-\.:\n]/_/g' > .list
# create sed commands
awk -F: '{print "s/" $1 "/'$file'_" $2 ".html/g;"}' .list > .sed
# create mv(1) shell script
perl -ne 'chop;($a,$b)=split(/:/);
print qq[rename ("$a", "$ENV{'file'}_$b.html") || ] .
qq[die "rename $a $ENV{'file'}_$b.html:\$\!";\n]' .list > .mv
# replace links
if [ -f "$file.ln" ]; then
perl -i -p .sed $file.ln
fi
# replace links
perl -i -p .sed $file*.html
# rename file names
perl .mv
rm -f .mv .sed .list
--
Wolfram Schneider <wosch@apfel.de> http://www.apfel.de/~wosch/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710090910.LAA00672>
