#!/usr/bin/perl -w
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#NAME
#  mktitlefiles -
#
#SYNOPSIS
#  ____ ...
#
#REQUIRES
#
#DESCRIPTION
# This is a one-shot script to create "template" page-title files in  a  list
# of  subdirectories.   The  files  are names NN00-Title.abc, where NN is the
# RSCDS booklet's number.  We should only need to do this once, then  when  a
# new booklet comes out, we can just use its Title file as a template. But we
# may keep this around just in case (and as a template for similar things  in
# other directories.
#
#OPTIONS
#
#EXAMPLES
#
#FILES
#
#BUGS
#
#SEE ALSO
#
#AUTHOR
#  John Chambers <jc@trillian.mit.edu> 2011-09-24
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #

$| = 1;
$exitstat = 0;
($P = $0) =~ s".*/"";
$V = $ENV{"V_$P"} || $ENV{"D_$P"} || 2;	# Verbose level.

$fr = 1; $to = 46;

book:
for ($bk = $fr; $bk <= $to; ++$bk) {
    $file = sprintf("Book%02d/%02d00_Title.abc",$bk,$bk);
    print "$P: $file\n" if $V>1;
    unless (open(F,">$file")) {
        print STDERR "$P: ### Can't write '$F' [$!]\n" if $V>0;
    } else {
		print F "X: $bk\n";
		print F "T: Scottish Country Dances\n";
		print F "T: RSCDS Book $bk\n";
		print F "K:\n";
    }
    close F;
}

print "$P: Exit with status $exitstat.\n" if $V>1;
exit $exitstat;

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
