#!/bin/bash
  
# This is a script to build a clean set of SIG/M volumes from available sources.
  
# --------
# VERSIONS
# --------
#   The latest version of this script is available at https://github.com/CPMArchives/SIGM.
#
#   2022-05-06 - A major rewrite of several portions:
#              - A major rewrite of the copyfiles function, allowing the caller to optionally
#                specify a list of files to be copied from the source.
#              - Changes to the build of several volumes (59, 60, 80, 84, 85, 87, 93, 105,
#                172, 291, 292) to clean up CRC mismatches.
#              - Other minor changes and bug fixes.
#
#   2022-04-14 - I've forgotten to track changes. See the github site above if you're interested.
#
#   2022-04-06 - Set date of ARK, LBR, DSK dirs to release date of vol 310.
#   
#   2022-04-05 - Initial release.

# ------------
# REQUIREMENTS
# ------------

#  ISOs (all available from the *HUMONGOUS CP/M* Archives):
  
#    cpmdosgg.iso                                             http://cpmarchives.classiccmp.org/downloads/cpmdosgg_iso.zip
#    sourdough_jims_cpm_archive.iso                           http://cpmarchives.classiccmp.org/downloads/sourdough_jims_cpm_archive.iso.zip
#    nicholson.iso                                            http://cpmarchives.classiccmp.org/downloads/nicholson.iso
#    November_1994_Walnut_Creek_cpm_cdrom.iso                 http://cpmarchives.classiccmp.org/downloads/November_1994_Walnut_Creek_cpm_cdrom.iso.7z
#    cpmug.iso                                                http://cpmarchives.classiccmp.org/downloads/cpmug.iso
#    oakcpm.iso                                               http://cpmarchives.classiccmp.org/downloads/oakcpm.iso.7z
  
#   Place the above ISOs together in an accessible directory and point the var $iso_loc below to it. 

#  Utilities

#   Make sure these are available somewhere in your system path.

#       imdu - Dave Dunfield's ImageDisk utility              http://dunfield.classiccmp.org/img/index.htm ; https://oldcomputers-ddns.org/public/pub/manuals/imd.pdf
#       arc  - a utility for handling CP/M .ARK archives      Debian: sudo apt install arc ; Source: https://github.com/ani6al/arc
#       crck - a utility for generating CPM-style CRC values  http://cpmarchives.classiccmp.org/cpm/mirrors/oak.oakland.edu/pub/unix-c/cpm/crck.tar.Z
#   cpmtools - specifically cpmcp                             http://www.moria.de/~michael/cpmtools/ ; https://github.com/lipro-cpm4l/cpmtools/tree/cpm4l/cpmtools-2.21
#      mklbr - create .lbr archives                           https://github.com/ogdenpm/mklbr

# -----
# USAGE
# -----

#   Place this script somewhere on your system. Read these comments for details. Download the ISO images and make sure you 
#   have all the required utilities installed (see the REQUIREMENTS section above) and available in your system path. Then 
#   edit two variables in the VARIABLES section: $iso_loc and $buildroot. Or just place the ISOs and this script together 
#   in the current directory. You can now build a single volume; e.g.:

#     ./buildvol 228

#   Or the entire collection (on my system this takes a bit over five minutes):

#     for i in {1..310}; do ./buildvol $i; done

# ------- ----
# PROJECT GOAL
# ------- ----

# While there are several sources currently available for the SIG/M collection, none of them is "clean" or complete. Some
# sources have accreted a number of additional files (cf. Walnut Creek), have corrupted file names (ibid.), have stripped
# CP/M record padding, or have converted text files to UNIX format. This clean-up will focus on the following four areas:

# Complete Collection
# -------- ----------
# Individually, none of the extant sources has all 310 volumes; prominently, volumes 184-192 are missing from most. Using all
# known sources, a complete SIG/M collection is assembled, including the missing vols 184-192.

# Volume Content
# ------ -------
# Occasionally, files have gone missing from some sources. More commonly, some sources (looking at you, Walnut Creek), have
# accreted additional files. For volume content, -CATALOG and (where available) CRCKFILE are considered canonical. Only files
# listed there are included, with three exceptions: CRCKFILE itself, CRCK.COM and SIG/M.LIB. In early volumes CRCK.COM appears
# only in CRCKFILE; likely it was added after -CATALOG was built. In later volumes when CRCs have moved into -CATALOG CRCK.COM,
# and SIG/M.LIB appear in the file lists only inconsistently, when they are present in the sources they are retained.

# File Names
# ---- -----
# File names have suffered a number of corruptions. Some characters, such as /, @ and +, which are legal under CP/M, are prob-
# lematic under other file systems, and are often found altered. / is a special problem, which has played havoc in UNIX environ-
# ments (cf. volume 195 on the Walnut Creek CD). It is stored properly as / inside the ARK, LBR and DSK images created here, but
# as _ (underscore) on the host system.

# File Dates
# ---- -----
# The CP/M file system had no capacity for storing file dates, so the original files had none. The decision has been made to
# set dates on individual files to match their volume's release date, but keep in mind that these, too, are artificial.
#
# Exceptions are CRCK.COM (CRC.COM beginning with vol 73) and SIG/M.LIB, which appear in multiple volumes. So long as they remain 
# identical to earlier versions, their dates will be set to the date of their earliest appearance in the SIG/M collection.

# File Integrity
# ---- ---------
# CP/M had no facility for recording exact file sizes, but stored files in 128-byte records. Thus typically a file, unless it
# happened to be exactly some multiple of 128 bytes in length, was padded with a number of "garbage" bytes (commonly 1AH, since
# CP/M filled freshly formatted disks with 1AH which also doubled as an end-of-file marker for text files under CP/M) to the next
# multiple of 128 bytes. However, when the SIG/M collection passed through other OSes text files often lost this padding. Though 
# not detrimental, this resulted in CRCs which no longer match those in -CATALOG or CRCKFILE listings. This project restores the 
# padding to all files that are not an exact multiple of 128 bytes in length, restoring in almost all cases original CRCs.

#----------
# VARIABLES
#----------

  # Set $vol, verifying that a valid number between 1 and 310 has been supplied. Note: haven't tested for edge case of "0000".

  [[ -z $1          ]] && { echo "No volume specified. You must specify a volume between 1 and 310; e.g., buildvol 52." ; exit 1; } 
  [[ $1 =~ ^[0-9]+$ ]] || { echo "$1 is not a number.  You must specify a volume between 1 and 310; e.g., buildvol 52." ; exit 1; } 
  vol=$1; while [ "$(echo ${vol:0:1})" == "0" ]; do vol=$(echo $vol | cut -b2-); done # strip leading zeroes
  [[ $vol -lt 1  ]] || [[ $vol -gt 310 ]] && { echo "Invalid volume number. You must specify a volume between 1 and 310; e.g., buildvol 52."; exit 1; } 
   
  # Vol num is needed in two formats, as a 3-char string with leading zeroes for string manipulation and as a numerical value for numeric
  # comparisons. We will store it as a 3-char string with leading zeroes, then use $(striplz) to convert it on-the-fly to a numeric value.
  
   vol=`printf %03d $vol`                                                              # Pad $vol to three digits with leading zeroes
   [[ -z "$iso_loc" ]] && iso_loc=$(pwd)                                               # Where you SIG/M source ISOs are (default current dir)
   [[ -z "$buildroot" ]] && buildroot=$(pwd)                                           # Where the rebuilt vols will be saved (default curr dir); 
   mkdir -p $buildroot                                                                 # each will be in a subdir called sigmv###/

  builddir=$buildroot/sigmv$vol ; rm -rf $builddir > /dev/null 2>&1 ; mkdir -p $builddir
  
# ---------
# FUNCTIONS
# ---------

#   STRIPLZ - Strip leading zeroes from a number so it doesn't get treated as hex.
#    SOURCE - Mounts the source specified ("cpmdosgg", "oak", etc.) in preparation to copy the files. Mostly called from COPYFILES.
# COPYFILES - Copies files from the source, uppercasing all filenames. Also corrects a few corrupted names.
# DATEFILES - Sets the file datestamps to the date of release of that volume; in most cases pulls the date from -CATALOG.
#  CHECKCRC - an attempt to automate CRC comparison, but it may be hopelessly messy. Not currently used.
#       CRC - returns the CRC value of a file
#  DISMOUNT - Unmount the source mounted with SOURCE. Mostly called from COPYFILES.
#    RENAME - Renames files.
#       ARK - Creates a VOL###.ARK archive file. Requires cpmtools.
#       DSK - Creates an IBM-3740-format disk image for use in CP/M emulators.
#       LBR - Creates a CP/M-style LBR archive.
#  ARCHIVES - Master routine that calls ARK, DSK and LBR.
#    REMOVE - Deletes files.                       
#       PAD - Pads file lengths with 1AH out to 128-byte multiples.
#   PADNULL - Same as PAD, but pads with 00H instead of 1AH; used only in vol 285.
#     NOTES - Spit out some notes at the end.


# ------------
  striplz () { 
# ------------
  # Strip leading zeroes from a number; e.g., 003 --> 3 to allow numeric comparisons. Invoke as follows:
  
  #   [[ $(striplz $vol) -ge 59 ]]
  
  # If invoked without a parameter, defaults to $vol, so mostly can simply be evoked as $(striplz)
  
  # Note to future self: if you land here thinking, "Hey, I can do this with echo $((10#$vol)))" DON'T DO IT. BASH will
  # attempt to treat $vol as a hex value if it has a leading zero, and will choke on 009, 099, etc., which are invalid
  # hex. Also it will convert things like 0121 to 81.
  
    [[ -z $1 ]] && z=$vol || z=$1  
    while [ "$(echo ${z:0:1})" == "0" ]; do z=$(echo $z | cut -b2-); done              # strip all leading zeroes manually
    echo $z
  }  

# ------------
  source () { 
# ------------
  # Sources for the SIG/M collections are various ISO images from *HUMONGOUS* CP/M: nicholson.iso, cpmdosgg.iso, cpmug.iso, 
  # sourdough_jims_cpm_archive.iso, November_1994_Walnut_Creek_cpm_cdrom.iso and oakcpm.iso, placed in a single location 
  # which is specified in $iso_loc above.
  
  # The rest of this script assumes $src is pointed at the source from which the volume's content will be pulled. This 
  # function's job is to point $src at the right place depending on which collection is being used for the source. E.g., if 
  # the volume is 25 and nicholson is the source: mount nicholson.iso to $tempdir, then point $src at $tempdir/extract/cpmug025.
  
  tempdir=$(pwd)/temp                                                                  # a working directory where the source iso will be mounted
  mountpoint -q $tempdir && sudo umount -l $tempdir > /dev/null 2>&1                   # ensure a fresh tempdir
  [[ -d $tempdir ]] && rm -rf $tempdir              > /dev/null 2>&1
  mkdir -p $tempdir                                 > /dev/null 2>&1
  
  # You can change these if you want. $iso_loc is set in VARIABLES above.

   cpmdosgg_iso=$iso_loc/cpmdosgg.iso
      cpmug_iso=$iso_loc/cpmug.iso 
       nich_iso=$iso_loc/nicholson.iso 
         wc_iso=$iso_loc/November_1994_Walnut_Creek_cpm_cdrom.iso
        oak_iso=$iso_loc/oakcpm.iso 
  sourdough_iso=$iso_loc/sourdough_jims_cpm_archive.iso  

  case $1 in
     cpmdosgg) # SIG/M vols 1-280 are found in CPMDOSGG dirs cpm10/, cpm11/ and cpm12/.
               mkdir -p $tempdir
               [[ -f $cpmdosgg_iso ]] && sudo mount $cpmdosgg_iso  $tempdir/ > /dev/null 2>&1 || { echo $(basename $cpmdosgg_iso) not found. Specify the location of your ISO files with:; echo ""; echo "export iso_loc=/path/to/ISOs"  ; exit 1; } 
               src=$tempdir/cpm1${vol:0:1}/1$vol/
               ;;
        cpmug) # SIG/M vols 2, 4, etc. are duplicated in CPMUG vols 56, 58, etc.
               mkdir -p $tempdir
               [[ -f $cpmug_iso ]] && sudo mount $cpmug_iso     $tempdir/ > /dev/null 2>&1 || { echo $(basename $cpmug_iso) not found. Specify the location of your ISO files with:; echo ""; echo "export iso_loc=/path/to/ISOs"   ; exit 1; }
               [[ $vol == 002 ]] && src=$tempdir/cpmug056
               [[ $vol == 004 ]] && src=$tempdir/cpmug058
               [[ $vol == 005 ]] && src=$tempdir/cpmug059
               [[ $vol == 006 ]] && src=$tempdir/cpmug060
               [[ $vol == 011 ]] && src=$tempdir/cpmug057
               [[ $vol == 015 ]] && src=$tempdir/cpmug067
               ;;
    nicholson) # nicholson is a bit complicated. A partial SIG/M set is found in .IMD format in the sigm/ directory. Also, 
               # the directory extracted/ contains subdirs holding, apparently, the extracted contents of those IMD images. 
               # I'm not sure why I did that. Assuming the code below, using the imdu and cpmcp to extract the contents
               # works, just go with that. The way this code is currently structured, it seems to set up the extract/ source, 
               # then just switch to the IMD image anyway.
    
               mkdir -p $tempdir
               [[ -f $nich_iso ]] && sudo mount $nich_iso      $tempdir/ > /dev/null 2>&1 || { echo $basename $nich_iso not found. Specify the location of your ISO files with:; echo ""; echo "export iso_loc=/path/to/ISOs"   ; exit 1; }
               [[ -d $tempdir/extract/sigm$vol/     ]] && src=$tempdir/extract/sigm$vol/
               [[ -f $tempdir/sigm/sigm$vol.imd     ]] && { 
                 imdu -b $tempdir/sigm/sigm$vol.imd ./sigm$vol.dsk > /dev/null 2>&1
                 sudo umount -l $tempdir > /dev/null 2>&1
                 cpmcp -f ibm-3740 ./sigm$vol.dsk 0:*.* $tempdir/
                 rm -f ./sigm$vol.dsk
                 src=$tempdir
                 }
               ;;
           wc) # The Walnut Creek CD's copy of SIG/M is in simtel/sigm/ subdirs vols000/, vols100/, vols200/ and vols300/.
               mkdir -p $tempdir
               [[ -f $wc_iso ]] && sudo mount $wc_iso        $tempdir/ > /dev/null 2>&1 || { echo $wc_iso not found. Specify the location of your ISO files with:; echo ""; echo "export iso_loc=/path/to/ISOs"   ; exit 1; }
               src=$tempdir/simtel/sigm/vols${vol:0:1}00/vol$vol/
               ;;
          oak) # OAK's collection is in some ways the most complicated. While its collection is nearly complete complete 
               # (lackings vols 184-192), it is a mixture of expanded subdirs and .ARK archive files. Thus depending on the 
               # vol it can either be pulled from the expanded dir, or extracted from the .ARK archive.          
               mkdir -p $tempdir
               [[ -f $oak_iso ]] && sudo mount $oak_iso       $tempdir/ > /dev/null 2>&1 || { echo $oak_iso not found. Specify the location of your ISO files with:; echo ""; echo "export iso_loc=/path/to/ISOs"   ; exit 1; }
               [[ -d $tempdir/sigm/vol$vol/ ]] && src=$tempdir/sigm/vol$vol/ || {
                  curdir=$(pwd)
                  sudo cp $tempdir/sigm/sigmv$vol.ark $curdir/ # for some reason fails without sudo
                  sudo umount -l $tempdir > /dev/null 2>&1
                  cd $tempdir
                  arc ne $curdir/sigmv$vol.ark
                  cd $curdir/ > /dev/null 2>&1
                  rm -rf ./sigmv$vol.ark
                  curdir=
                  src=$tempdir
                  }
               ;;
    sourdough) # Sourdough's SIG/M collection is in library_collections/sigm/. Like OAK, it is a mixture of expanded
               # dirs and .ARK archives.
               mkdir -p $tempdir
               [[ -f $sourdough_iso ]] && sudo mount $sourdough_iso $tempdir/ > /dev/null 2>&1 || { echo $sourdough_iso not found. Specify the location of your ISO files with:; echo ""; echo "export iso_loc=/path/to/ISOs"   ; exit 1; }
               [[ -d $tempdir/library_collections/sigm/vol$vol/ ]] && src=$tempdir/library_collections/sigm/vol$vol || {
                  curdir=$(pwd)
                  cp $tempdir/library_collections/sigm/sigmv$vol.ark $curdir
                  sudo umount -l $tempdir > /dev/null 2>&1
                  cd $tempdir
                  arc ne $curdir/sigmv$vol.ark
                  cd $curdir/ > /dev/null 2>&1
                  rm -f $curdir/sigmv$vol.ark
                  curdir=
                  src=$tempdir
                  }
               ;;
  esac
  
  echo ""
  echo ""
  echo "============"                # Tell user where the contents are being pulled from
  echo "SIG/M VOL$vol Files from $1"
  echo "============"
  }  
  
# ------------
  crc () {
# ------------
    echo $(cpmcrck $1 | tail -1 | rev | cut -d' ' -f1 | rev)
  }
  
# ------------
  rename () {
# ------------
    # To rename single files (each pair wrapped in quotations):
    #   rename './oldname ./newname' './oldname ./newname'
    
    # To batch rename a wildcarded spec:
    #   rename 'DU_*.*'

    # NOTE: Use the wildcarded option only when you wish to replace _ with -.
    # If you wish to replace _ with some other char use single file format.
    
    cd $builddir >/dev/null 2>&1 
    echo ""
    echo "  Rename"
    echo "    ----"
    for i in "$@"; do 
      echo "$i" | grep "*" > /dev/null && { 
        for j in $i; do
          echo "    $j $(echo $j | tr '_' '-')"
          mv $j $(echo $j | tr '_' '-')
          done
        } || { echo "    $i"; mv $i; }
    done

    [[ $(striplz) -lt 193 ]] && [[ -f  $builddir/SIG-M.LIB ]] && mv $builddir/SIG-M.LIB $builddir/SIG_M.LIB 
    echo "    ----"
    cd - >/dev/null 2>&1 
  }
  
# ------------
  copyfiles () {
# ------------

    # Copy files. Invoked as: copyfiles source [filename] [filename] [...]  
    #
    # source is required and is one of wc, cpmug, oak, etc. (see function source above). You may optionally 
    # specify a list of files to copy (no wildcards); if no files are specified, all files will be copied.
    #
    # No error checking is done so make sure you have everything correct!

    source $1                                                                          # first parameter specifies the source to use

    echo ""
    echo "  Copying files"
    echo "    ----"
    echo "    From $src"
    shift                                                                              # discard the first param, leaving only the file list
    [[ -z "$1" ]] && {                                                                 # if no files were specified, assume *.*
      for f in $src/* ; do cp $f $builddir/$(basename $f | tr 'a-z' 'A-Z') >/dev/null 2>&1; done  # Uppercase all filename
      for i in ./_SIGM ./-SIGM ./_SIG_M ./-SIG_M; do                                   # Remove -SIGM.xxx, which were added in some collections
                                                                                       # as volume labels; but on vol 2 it's legit.
        [[ -f $builddir/$i.$vol ]] && rm -rf $builddir/$i.$vol >/dev/null 2>&1         # labels. They're not original, so clean them out.
      done                                                                        

      for i in ./_CATALOG ./CATALOG; do                                                # Rename back to -CATALOG
        [[ -f $builddir/$i.$vol ]] && mv $builddir/$i.$vol $builddir/-CATALOG.$vol >/dev/null 2>&1
      done  

      for i in ./SIG\$M.LIB ./SIG-M.LIB ./SIG_M.LIB; do                                # Rename SIG$M.LIB, SIG/M.LIB, SIG-M.LIB to SIG_M.LIB
        [[ -f $builddir/$i ]] && mv $builddir/$i $builddir/SIG_M.LIB >/dev/null 2>&1
      done  
    } || for f in $@; do cp $src/$f $builddir/$(basename $f | tr 'a-z' 'A-Z') >/dev/null 2>&1; done

    # SIG/M.LIB (aka SIG_M.LIB) changes names to SIG-M.LIB after vol 192 (except for 197).
    
    [[ $(striplz) -ge 193 ]] && [[ $(striplz) -ne 197 ]] && [[ -f $builddir/SIG_M.LIB ]] && mv $builddir/SIG_M.LIB $builddir/SIG-M.LIB # Vols 193+ except 197, name changed to SIG-M.LIB.
    sudo chmod 777 $builddir/*                                                         # Some vols (e.g., 104) give "Permission denied" 
    dismount                                                                           # when the script attempts to pad the files
    echo "    ----"
  }

# ------------
  datefiles () {
# ------------              

  # SIG/M began in about Sept 1980. For most volumes (ca. 43-310), release dates can be culled from -CATALOG. But earlier
  # volumes didn't include release dates, so dates used here are gleaned largely from the SIG/M newsletters on Vol 51; but
  # in most cases only the month can be gleaned. There's some indication that official release dates were the date of that
  # month's SIG/M meeting, but in most cases that date is unknown (Jun '81 is the exception; the 7/81 newsletter says June
  # 12th); so the 15th of the release month is arbitrarily assigned.
  
  # ---- Set VOLUME DATE and date stamp all files ----
  
    case $vol in            
      001) date=19801015 ;; # The 11/80 newsletter mentions three vols already available, 
      002) date=19801015 ;; # says four more would be released at that month's SIG/M mtg.
      003) date=19801015 ;; #     /
      004) date=19801215 ;; # NEWS1980.SIG says "Diskette  number  4" "was  defective", "was rebuilt" 
                            # and will be available "at the next users' group  meeting" (December?).
                            # Presumably it is the rebuilt vol that is available in the extant SIG/M
                            # collections, so a date of Dec 1980 is assigned to it.
      005) date=19801107 ;; # NEWS1980.SIG says vols 4-7 would be available at the Nov. 7 meeting.
      006) date=19801107 ;; #  /
      007) date=19801107 ;; # /
      008) date=19801215 ;; # No mention of vols 8-11 in the SIG/M newsletters, so for no
      009) date=19810115 ;; # good reason just assigning one per month until vol 12.
      010) date=19810215 ;; #  /
      011) date=19810315 ;; # /
      012) date=19810415 ;; # NEWS0481.SIG lists vols 12-16 as "new releases"
      013) date=19810415 ;; #    /
      014) date=19810415 ;; #   /
      015) date=19810415 ;; #  /
      016) date=19810415 ;; # /
      017) date=19810515 ;; # NEWS0581.SIG lists vols 17 and 18 as new releases
      018) date=19810515 ;; # /
      019) date=19810612 ;; # NEWS0681.SIG calls vols 12-25 "new releases", while NEWS0781.SIG
      020) date=19810612 ;; # gives the date as June 12.
      021) date=19810612 ;; #     /
      022) date=19810612 ;; #    /
      023) date=19810612 ;; #   /
      024) date=19810612 ;; #  /
      025) date=19810612 ;; # /
      026) date=19810901 ;; # 7/81 mentions no new releases. 8/81 says 11 vols will be released 
      027) date=19810901 ;; # "within the next month." 9/81 says SIG/M "has recently released 
      028) date=19810901 ;; # volumes 26 through  38".
      029) date=19810901 ;; #          /
      030) date=19810901 ;; #         /
      031) date=19810901 ;; #        /
      032) date=19810901 ;; #       /
      033) date=19810901 ;; #      /
      034) date=19810901 ;; #     /
      035) date=19810901 ;; #    /
      036) date=19810901 ;; #   /
      037) date=19810901 ;; #  /
      038) date=19810901 ;; # / 
      039) date=19811015 ;; # 10/81 lists vols 39-42 as "newly released"
      040) date=19811015 ;; #   /
      041) date=19811015 ;; #  /
      042) date=19811015 ;; # /
                            # 11/81 says 42 vols have been released, but no new releases are announced. 
                            # 12/81 lists vols 43-48 as "recent releases", but beginning with vol 43
                            # release dates are supplied in -CATALOG.
      052) date=19820101 ;; # No release date; assuming Vol 51/53's date.
      055) date=19820205 ;; # No release date; interpolating between vols 54/56.
      059) date=19820317 ;; # My date extraction code chokes on -CATALOG malformatting so
      092) date=19830114 ;; # ...specifying manually.
      093) date=19830115 ;; #          /                    
      118) date=19830614 ;; #         /                     
      128) date=19830909 ;; #        /                      
      129) date=19830909 ;; #       /                       
      135) date=19830901 ;; #      /                        
      153) date=19840206 ;; #     /                         
      291) date=19861121 ;; #    /
      292) date=19861121 ;; #   /
      293) date=19861121 ;; #  /
      294) date=19861121 ;; # /
      295) date=19870815 ;; # No release date. Assuming it goes with vol 296.
      296) date=19870815 ;; #    /
      297) date=19870815 ;; #   /
      298) date=19870815 ;; #  /
      299) date=19870815 ;; # /
      300) date=19870915 ;; # Release dates for vols 296-310 are MM/YY only; arbitrarily
      301) date=19870915 ;; # ...assigning the 15th of those months.
      302) date=19871115 ;; #         /
      303) date=19871115 ;; #        /
      304) date=19880315 ;; #       /
      305) date=19880315 ;; #      /
      306) date=19880315 ;; #     /
      307) date=19880315 ;; #    /
      308) date=19880315 ;; #   /
      309) date=19880315 ;; #  /
      310) date=19880315 ;; # /
        *) date=$(grep released $builddir/-CATALOG.$vol | rev | cut -d' ' -f1-3 | rev) ;;
    esac   
    echo ""
    echo "  VOL DATE"
    echo "    ----"
    echo "    $date"
    echo "    ----"

    touch -d "$date" $builddir/*  # datestamp the files
    touch -d "$date" $builddir    # and the directory

    # ---- UTILITY FILES ----
    
    # A few utility files, such as CRC.COM or SIG/M.LIB, appear throughout the SIG/M collection. Rather than dating each instance 
    # to the release date of the volume it appears in, it make sense to date all occurrences to the date of its first appearance 
    # in the SIG/M collection. Various versions of a file are distinguished by CRC.
    
    for i in CRC.COM SIG_M.LIB SIG-M.LIB USQ.COM LU.COM JOIN.ACG DELBR.COM DELBRA.COM CRC.CMD USQ.CMD; do
                                                                                          # Could do "for i in $builddir/*", but there are
                                                                                          # occasional CRC collisions in the collection; 
                                                                                          # calling out specific names minimizes the poten-
                                                                                          # tial of a CRC value misidentifying a different file.

      [[ -f $builddir/$i ]] && {                                                          # if the file exists in the current volume
        case $(crc $builddir/$i) in                          
          151e) d=19801115 ;; c9be) d=19801215 ;; 93ae) d=19830214 ;; 1539) d=19830614 ;; # SIG/M.LIB
          d31c) d=19841116 ;; 15ca) d=19841221 ;; 0c6f) d=19850920 ;; f4dd) d=19861121 ;; # SIG/M.LIB  
          b207) d=19820926 ;; bb23) d=19830214 ;; ee87) d=19850118 ;; cb3e) d=19870815 ;; # CRC.COM
          053b) d=19870515 ;;                                                             # CRC.COM
          24c0) d=19840203 ;; f46e) d=19840601 ;; eb7c) d=19850118 ;; 0caf) d=19850517 ;; # USQ.CMD 
          561f) d=19811125 ;; 5621) d=19831202 ;; 7d52) d=19840601 ;;                     # USQ.COM
          83e7) d=19831007 ;; 9b11) d=19840106 ;;                                         # JOIN.ACG
          3d98) d=19830909 ;; ba32) d=19840106 ;;                                         # LU.COM
          f628) d=19841116 ;;                                                             # SHOW.COM
          ef3a) d=19841005 ;;                                                             # DELBR.COM DELBRA.COM
          10e5) d=19841221 ;;                                                             # CRC.CMD 
        esac

        touch -d "$d"    $builddir/$i                                                     # This will reset $builddir to current time so...
        touch -d "$date" $builddir                                                        # ...reset it
      }
    done
    } 
  
# ------------
  checkcrc () {
# ------------

    # Verify file integrity by comparing the file's actual CRC with the listed CRC: 1) get the file's actual CRC with cpmcrck. 
    # 2) Extract the CRC from $crcfile with grep and cut. 3) Compare.
    
    echo ""
    echo "  File Integrity"
    cd $builddir >/dev/null 2>&1
    echo "    ----"
    
    # A combination of $fields and $bytes is used to extract the file's listed CRC value from $crcfile. $crcfile is one of 
    # CRCKFILE.$vol, CRCKLIST.$vol or -CATALOG.$vol. For most volumes, these defaults work:
    
    crcfile="./-CATALOG.$vol" ; fields="-f3" ; bytes="-b13-17" # defaults

    # Put exceptions here. I previously used [[ $(echo $((10#$vol))) -le  18 ]]. Now using $(striplz). Note: this is for 
    # volume-wide settings. Any individual file within a volume that needs special attention is handled below.
    
    [[ $(striplz) -le  18 ]]                             && { echo "    No CRCs available"  ; echo "    ----" ; return   ; } # Vols 1-18 no CRCs
    [[ $(striplz) -le  25 ]]                             && { crcfile="./CRCKFILE.$vol" ; fields="-f2" ; bytes="-b12-16" ; } # Vols 19-25
    [[ $(striplz) -ge  26 ]] && [[ $(striplz) -le  48 ]] && { crcfile="./CRCKLIST.$vol" ; fields="-f2" ; bytes="-b12-16" ; } # Vols 26-48
    [[ $(striplz) -ge  49 ]] && [[ $(striplz) -le  50 ]] && {                                            bytes="-b9-13"  ; } # Vols 49-50
    [[ $(striplz) -eq  51 ]] &&                             {                                            bytes="-b5-9"   ; } # Vol  51
    [[ $(striplz) -ge  52 ]] && [[ $(striplz) -le  75 ]] && {                                            bytes="-b9-13"  ; } # Vols 52-75
    [[ $(striplz) -eq  76 ]] || [[ $(striplz) -eq  78 ]] && {                                            bytes="-b11-15" ; } # Vols 76, 78
    [[ $(striplz) -ge  83 ]] && [[ $(striplz) -le  84 ]] && {                                            bytes="-b11-15" ; } # Vols 83, 84
    [[ $(striplz) -ge  86 ]] && [[ $(striplz) -le  93 ]] && {                                            bytes="-b11-15" ; } # Vols 86-93
    [[ $(striplz) -ge  94 ]] && [[ $(striplz) -le 114 ]] && {                                            bytes="-b12-16" ; } # Vols 94-114

    # Cycle through the files in the current volume: get the actual CRC, build the name to grep -CATALOG for, extract the listed CRC, then compare.
    # Along the way we'll have to deal with certain special cases.
    
    for i in ./*; do actualcrc="$(cpmcrck $i | tail -1 | cut -b46-50 | tr 'a-z' 'A-Z')" # get the file's actual CRC

      # File names are listed in -CATALOG right-padded to 8.3 with spaces; e.g., "CRC.COM" is listed as "CRC     .COM".
      # Here we build the "expanded name" so we can search for it.
      
      f=$(basename $i) 
      name=$(echo $f | cut -d'.' -f1)                                                  # strip './' and grab filename portion without extension
      ext=$( echo $f | cut -d'.' -f2); [[ $ext == $name ]] && ext="   "                # grab filename ext only; set to '   ' if none
      expandedname="$(printf "%-8.15s.%s" $name $ext)"                                 # Pad out to full 8.3; e.g., "CRC.COM" to 'CRC     .COM'

      [[ ! "$ext" == "$vol" ]] && [[ ! "${f:0:1}" == "-" ]] && {                       # Skip any file whose extension is the vol number 
                                                                                       # (-CATALOG.049) or whose name starts with -.

        # Sometimes an individual file's entry in -CATALOG is formatted differently from the rest; e.g., 
        # its CRC value occurs in a different place on its line. Specify that here.
      
        orgbytes=$bytes                                                                # Save current value for later restoration

        case $f in
           "ARCUSTM.DCL" )                  bytes="-b10-14" ;;                         # Vol 49
          "CHGLIB22.LBR" )                  bytes="-b10-14" ;;                         # Vol 250
          "PRAELUD1.SNG" | "SCARLATI.SNG" ) bytes="-b10-14" ;;                         # Vol 57
            "FLS-11.COM" )                  bytes="-b16-20" ;;                         # Vol 60
                  "NEWS" )                  bytes="-b11-15" ;;                         # Vol 249
              "SYOPMENU" )                  bytes="-b10-14" ;;                         # Vol 249
        esac
          
        # While the above expanded name process mostly works correctly, there are a few fails and of course there are always exceptions.
        
        case $expandedname in 
          "PISTOL  .C"   ) grepname="PISTOL  .C "                                    ;; # Vols 59, 114; add space to avoid matching PISTOL.COM or PISTOL.CRC
          "XLISP   .C"   ) grepname="XLISP   .C "                                    ;; # Vols 118,153; add space to avoid matching XLISP.COM
          "SCRUB   .C"   ) grepname="SCRUB   .C "                                    ;; # Vol  157    ; add space to avoid matching SCRUB.COM
          "READ    .ME"  ) grepname="READ    .ME "                                   ;; 
          "CRC     .COM" ) [[ $(striplz) -eq 89  ]] || [[ $(striplz) -eq 108 ]] && grepname="CRC    .COM" ;;  # Vol 89 -CATALOG lists CRC.COM as "CRC    .COM" (only 4 spaces)
          "GLOBALS .RN$" ) grepname="GLOBALS .RN"                                    ;; # Vol 134
          "HELP    .COM" ) [[ $(striplz) -eq 89  ]] && grepname="HELP   .COM"        ;; # Vol 89 -CATALOG lists HELP.COM as "HELP   .COM" (only 3 spaces)
          "JOIN    .ACG" ) [[ $(striplz) -eq 89  ]] && grepname="JOIN.ACG"           ;; # Vol 146
          "PASZCODE.RN$" ) grepname="PASZCODE.RN"                                    ;; # Vol 134
          "MDBSGETM.PLI" ) grepname="MDBSGETM.PL"                                    ;; # Vol 49
          "PRICES  .DOC" ) grepname="PRICES.DOC"                                     ;; # Vol 53
          "SIG_M   .LIB" ) [[ $(striplz) -eq 146 ]] && grepname="SIG/M.LIB" || grepname="SIG/M   .LIB" # Vol 146
                           [[ $(striplz) -ge 193 ]] && grepname="SIG-M   .LIB"          # Vols 193-310; this may no longer be necessarily as I now rename SIG_M to SIG-M on vols 193+.
                           ;;
          "LIB     ."    ) grepname="LIB     .LIB"                                   ;; # Vol 270
          "ZEX     ."    ) grepname="ZEX     .ZEX"                                   ;; # Vols 99, 186
          "TESTPROT.BAS" ) grepname="TestProt.BAS"                                   ;; # Vol 52
          "Z2SYS-1 .MOD" ) grepname="Z2SYS-1.MOD"                                    ;; # Vol 108
                        *) grepname=$(echo "$expandedname" | tr '_' '/')             ;; # Replace _ with / before grepping.
        esac
  
        # grep $grepname in $crcfile. If not found, report; if found, extract the CRC.
        
        grep -i "$grepname" $crcfile >/dev/null || echo "    $expandedname not listed in $crcfile" 
        grep -i "$grepname" $crcfile >/dev/null && { 
        
          # Generally, a file's CRC is grepped from $crcfile; but as always, there are exceptions, particularly utility files such as CRC.COM, 
          # JOIN.ACG, SIG/M.LIB, whose CRCs aren't supplied in $crcfile.

          # To manually check all the CRCs of a given filename, go to $buildroot and run: for i in {001..310}; do [[ -f sigmv$i/CRC.COM ]] && cpmcrck sigmv$i/$fn | tail -1; done
          
          case $f in
            
            "CRC.CMD"      ) expectedcrc=10E5 ;;                                                          
            "CRC.COM"      )                             expectedcrc=B207
                             [[ $(striplz) -eq 102 ]] && expectedcrc=BB23
                             [[ $(striplz) -ge 216 ]] && expectedcrc=EE87
                             [[ $(striplz) -ge 295 ]] && expectedcrc=CB3E
                             [[ $(striplz) -eq 296 ]] && expectedcrc=053B
                             [[ $(striplz) -eq 299 ]] && expectedcrc=EE87
                             [[ $(striplz) -ge 300 ]] && expectedcrc=B207
                             [[ $(striplz) -eq 303 ]] && expectedcrc=EE87
                             ;;                 
            "CRCK.COM"     ) expectedcrc=2D47 ;;
            "DELBR.COM"    ) expectedcrc=EF3A ;; 
            "DELBRA.COM"   ) [[ $(striplz) -ge 240 ]] && expectedcrc=EF3A ;;
            "HELP.COM"     ) expectedcrc=D6CC ; [[ $(striplz) -eq 102 ]] && expectedcrc=3447 ; [[ $(striplz) -ge 186 ]] && expectedcrc=928B ;;
            "JOIN.ACG"     ) expectedcrc=83E7 ; [[ $(striplz) -ge 153 ]] && expectedcrc=9B11 ; [[ $(striplz) -ge 173 ]] && expectedcrc=83E7 ; [[ $(striplz) -ge 282 ]] && expectedcrc=A289 ; [[ $(striplz) -ge 295 ]] && expectedcrc=83E7 ;;
            "JOIN.AZG"     ) expectedcrc=3EC0 ; [[ $(striplz) -ge 305 ]] && expectedcrc=3E32 ;;
            "LTYPE.COM"    ) expectedcrc=AC16 ;;                                                          
            "LU.COM"       ) expectedcrc=3D98 ; [[ $(striplz) -ge 157 ]] && expectedcrc=BA32 ;; 
            "LU86.CMD"     ) expectedcrc=1723 ;;   
            "MDBSGETM.PLI" ) expectedcrc=B7A1 ;;                                       # Vol 49
            "PRICES.DOC"   ) expectedcrc=6CC7 ;;                                       # Vol 53
            "READTHIS"     ) expectedcrc=2AE0 ; [[ $(striplz) -eq 173 ]] && expectedcrc=BB80 ; [[ $(striplz) -eq 197 ]] && expectedcrc=58FF ;; # Vols 164-166
            "READ.ME"      ) [[ $(striplz) -eq  54 ]] && expectedcrc=D7AB 
                             [[ $(striplz) -eq  56 ]] && expectedcrc=BEEB 
                             [[ $(striplz) -eq  57 ]] && expectedcrc=7AF9 
                             [[ $(striplz) -eq  59 ]] && expectedcrc=D3D3 
                             [[ $(striplz) -eq  61 ]] && expectedcrc=C847 
                             [[ $(striplz) -eq 114 ]] && expectedcrc=7CFF 
                             [[ $(striplz) -eq 173 ]] && expectedcrc=7CFF 
                             [[ $(striplz) -eq 184 ]] && expectedcrc=D9F5 
                             ;;
            "READTHIS.1ST" ) expectedcrc=CCAE ;; # Vol 168
            "REGIONS.SIG"  ) expectedcrc=3214 ; [[ $(striplz) -ge 252 ]] && expectedcrc=FD05 ;;
            "SHOW.COM"     ) expectedcrc=F628 ; [[ $(striplz) -eq 186 ]] && expectedcrc=808A ;; # Vol 186
            "SIG_M.LIB"    )                             expectedcrc=C9BE
                             [[ $(striplz) -eq 104 ]] && expectedcrc=93AE
                             [[ $(striplz) -ge 118 ]] && expectedcrc=1539 
                             ;;
            "SIG-M.LIB"    ) [[ $(striplz) -ge 193 ]] && expectedcrc=1539
                             [[ $(striplz) -ge 200 ]] && expectedcrc=D31C
                             [[ $(striplz) -ge 208 ]] && expectedcrc=15CA
                             [[ $(striplz) -eq 243 ]] && expectedcrc=0C6F
                             [[ $(striplz) -eq 253 ]] && expectedcrc=0C6F
                             [[ $(striplz) -ge 278 ]] && expectedcrc=0C6F
                             [[ $(striplz) -ge 291 ]] && expectedcrc=F4DD
                             [[ $(striplz) -ge 295 ]] && expectedcrc=15CA
                             ;;                 
            "ZEX.ZEX"      ) [[ $(striplz) -eq  99 ]] && expectedcrc=5328 ; [[ $(striplz) -eq 186 ]] && expectedcrc=782C ;;
            "SIG/M.LIB"    ) expectedcrc=C9BE ;;                                                          
            "SIG-M.LZB"    ) expectedcrc=F286 ;;                                                          
            "TYPE1.COM"    ) expectedcrc=56FB ; [[ $(striplz) -ge 184 ]] && expectedcrc=FFD7 ;; 
            "USQ.COM"      ) expectedcrc=561F ; [[ $(striplz) -ge 152 ]] && expectedcrc=5621 ; [[ $(striplz) -ge 176 ]] && expectedcrc=7D52 ;;
            "USQ.CMD"      ) expectedcrc=24C0 ; [[ $(striplz) -ge 175 ]] && expectedcrc=F46E ; [[ $(striplz) -ge 207 ]] && expectedcrc=24C0 ; [[ $(striplz) -ge 210 ]] && expectedcrc=EB7C ; [[ $(striplz) -ge 229 ]] && expectedcrc=0CAF ;;
            "Z2SYS-1.MOD"  ) expectedcrc=3DF1 ;;                                       # Vol 108
            "ZCPR2.IDX"    ) expectedcrc=63C6 ; [[ $(striplz) -eq 104 ]] && expectedcrc=BCB0 ; [[ $(striplz) -ge 124 ]] && expectedcrc=0BA7 ;;
            "ZCPR3.CAT"    ) expectedcrc=95F2 ;;
                          *) expectedcrc=$(grep -a "$grepname" $crcfile | cut -d'.' $fields | cut $bytes | tr -d [:space:] | cut -b1-4) ;;
          esac
          
          # Finally, if the actual and listed CRCs don't match, report it.
          
          [[ ! "$actualcrc" == "$expectedcrc" ]] && echo "    Vol $vol: $expandedname CRC mismatch **** ACTUAL: $actualcrc EXPECTED: $expectedcrc"
        }

       bytes=$orgbytes # restore original value in case it was altered, so the rest of the files in 
                       # this volume aren't processed with the wrong value.
       }  
    done

    echo "    ----"
    cd - >/dev/null 2>&1
  }
  
# ------------
  dismount () {
# ------------
    mountpoint -q $tempdir > /dev/null 2>&1 && sudo umount -l $tempdir > /dev/null 2>&1
    rm -rf $tempdir > /dev/null 2>&1
  }
  
# ------------
  ark () {
# ------------
    which arc    &> /dev/null 1>&2 || { echo "arc util not found"     ; return; }
    dest=$buildroot/ARK; arkname=$dest/SIGMV$vol.ARK
    cd                   $builddir                  &> /dev/null 1>&2
    mkdir -p             $dest                      &> /dev/null 1>&2
    [[ -f                $arkname ]] && rm $arkname &> /dev/null 1>&2                  # remove any previous version

    # build archive
    arc a                $arkname ./*               &> /dev/null 1>&2

    # On my Linux system I'm using arc v5.21r, which translates between / and :. But on the host system, I've replaced / with _, 
    # which arc doesn't pick up, so here I'll manually convert _ to / inside the ARK files. Note that arc will translation / to : 
    # when listing or extracting the ARK contents, but internally it is stored as /.

    for j in ./*; do {
      oldname=$(echo $(basename $j) | cut -d'.' -f1)                                   # filename with _
      newname=$(echo $oldname | tr '_' '/')                                            # filename with /
      [[ ! "$oldname" == "$newname" ]] && sed -i "s|$oldname|$newname|g" $arkname      # could also do something like echo $newname | grep "/"
      }
    done
    
    touch -r .           $arkname                   &> /dev/null 1>&2                  # set datestamp of ARK
    touch -d "19880315"  $dest                                                         # set datestamp of ARK dir to date of most recent SIG/M volume (i.e., vol 310)
    
    # clean up
    cd -                                            &> /dev/null 1>&2
    echo "    $(basename $arkname)"
  }
  
# ------------
  dsk () {
# ------------

    # IBM-3740-format images are created as I had made the assumption that SIG/M volumes were 
    # originally transferred on IBM-3740 disks. It appears other formats were also supported
    # (note it specifies only "8 inch"; it's only an assumption that was IBM-3740).
    
    # The 5/81 SIG/M Newsletter (see Vol 51) indicates the following formats were offered:
    
    #     8 inch single density     
    #      TRS-80 Model 2           
    # 5 1/4 inch  varieties:
    #      Micropolis Mod II        
    #      Northstar (SS/SD)        
    #                (SS/DD)        
    #      TRS-80    Model 1        
    #                Model 3        
    #      Apple    (13 sector)     
    #               (16 sector)     
    #      Cromemco  (SS/SD)        
    
    # While 6/81 said:
    
    # All SIG/M libraries on:     are up to volume:
    #                    8 Inch           25
    #                    Northstar DD     25
    #                    Micropolis ModII 25
    #                  * Apple CPMUG      n/a yet
    #                  * TRS-80 Mod 1/3   n/a yet
    #                           Mod 2     25  CP/M
    #                  * H-89             n/a yet
    #                  * Superbrain       n/a yet
    #  * means its in the process of creation
    
    # And 11/81 said:
    
    # We  are  officially  supporting  the following  5  and  1/4  inch formats:

    #  Micropolis Mod 2 (1 diskette per volume)
    #  North Star double density (2 diskettes per volume)
    #  TRS80 Mod 1 and 3 (3 to 4 diskettes per volume)
    #  Apple 2 (3 to 4 diskettes per volume)

    which mkfs.cpm &> /dev/null 1>&2 || { echo "mkfs.cpm util not found"; return; }
    which cpmcp    &> /dev/null 1>&2 || { echo "cpmcp util not found"   ; return; }
    dest=$buildroot/DSK; dskname=$dest/SIGMV$vol.DSK
    cd                   $builddir                  &> /dev/null 1>&2
    mkdir -p             $dest                      &> /dev/null 1>&2
    [[ -f                $dskname ]] && rm $dskname &> /dev/null 1>&2                  # remove any previous version

    # build archive
    mkfs.cpm -f ibm-3740 $dskname                   &> /dev/null 1>&2
    cpmcp -f    ibm-3740 $dskname ./* 0:            &> /dev/null 1>&2
    touch -r .           $dskname                   &> /dev/null 1>&2                  # set datestamp of DSK
    touch -d "19880315"  $dest                                                         # set datestamp of DSK dir to date of most recent SIG/M volume
    
    # clean up
    cd -                                            &> /dev/null 1>&2
    echo "    $(basename $dskname)"
  }

# ------------
  lbr () {
# ------------
    which mklbr &> /dev/null 1>&2   || { echo "mklbr util not found"   ; return; }
    dest=$buildroot/LBR; lbrname=$dest/SIGMV$vol.LBR ; recipe=$dest/$vol.rcp
    cd                   $builddir                  &> /dev/null 1>&2
    mkdir -p             $dest                      &> /dev/null 1>&2
    [[ -f                $lbrname ]] && rm $lbrname &> /dev/null 1>&2                  # remove any previous version

    # build archive
    echo                "$lbrname"       > $recipe
    for j in *; do echo "$builddir/$j?$(echo $j | tr '_' '/')"  >> $recipe; done
    mklbr                $recipe
    rm                   $recipe
    
    touch -r .           $lbrname                   &> /dev/null 1>&2                  # set datestamp of LBR
    touch -d "19880315"  $dest                                                         # set datestamp of LBR dir to date of most recent SIG/M volume (i.e., vol 310)

    # clean up
    cd -                                            &> /dev/null 1>&2
    echo "    $(basename $lbrname)"
  }
  
# ------------
  archives () { # calls the functions for building the ARK, DSK and LBR archives
# ------------
    echo ""
    echo "  Archives"
    echo "    ----"
    ark; dsk; lbr 
    echo "    ----"
  }

# ------------
  remove () { # delete the specified files
# ------------
    echo ""
    echo "  Remove"
    echo "    ----"
    while [[ ! -z $1 ]]; do
     for i in $1; do
       echo "    $i"
       rm --force $builddir/$i > /dev/null 1>&2
     done
     shift
    done 
    echo "    ----"
  }
  
# ------------
  pad () {
# ------------

  # Under CP/M all files were stored in 128-byte records, such that files which were not a multiple of 128 bytes
  # in length were padded with garbage to the next 128-byte boundary (If the files were originally copied to 
  # fresh disks, the padding consisted of 1AH bytes). Over many years of passing through various file systems, 
  # many of the text files in the SIG/M collection have lost that additional padding, resulting in files which no
  # match the original CRC values. This routine will pad any file whose length is not an exact multiple of 128 to 
  # the next 128-byte multiple with 1AH. This fixes most CRC mismatches.

    sudo chmod 777 $builddir/*                                                         # Some vols (e.g., 104) give "Permission denied"

    echo ""
    echo "  Padding"
    echo "    ----"

    for f in $builddir/*; do
      count=$((128-$(($(ls -l $f | cut -d' ' -f5)%128))))                              # number of bytes needed to next 128
      [[ $count -eq 128 ]] && count=0 || echo "    $(basename $f) with $count bytes"   # Reset to 0 to avoid padding files that are already a multiple of 128 bytes
 
      for (( c=1; c<=$count; c++)); do 
        printf "%b" '\x1A' >> $f
      done  
    done  

    echo "    ----"

  }

# ------------
  padnull () {
# ------------

  # A special version of pad that pads with null (00H) rather than 1AH. Used only from some files in
  # vol 285. The files are in UNIX /r format, so must first be converted to DOS /r/n. Then a single
  # EOF (Crl-Z or 1AH) byte is added to the end of the file. Finally, the file is padded out to 128
  # with null (00H) instead of 1AH that the pad function above uses.

    cd $builddir
    sudo chmod 777 ./*

    echo ""
    echo "  Null Padding"
    echo "    ----"

    for f in BRIEF-TS.HOW BROWSE.DOC CURSOR.ASM SAVEREST.ASM SAVEREST.DOC TWENTY.ASM WORD-KEY.FIX; do
      echo "    $f"
      unix2dos -f $f>/dev/null 2>&1
      printf "%b" '\x1A' >> $f
      count=$(( 128 - $(ls -l $f | cut -d' ' -f5) % 128 ))
      [[ $count -eq 128 ]] && count=0
      for (( c=1; c<=$count; c++)); do printf "%b" '\x00' >> $f; done  
     done  

    echo "    ----"
  }

# ------------
  notes () { # output any notes you want for the volume
# ------------
    echo ""
    echo "  Notes"
    echo "    ----"
    for i in "$@"; do echo "    $i"; done
    echo "    ----"
  }

#-----
# MAIN
#-----

# To verify everything is working, I have manually compared all volumes' CRCs and filenames to crckfile/crcklist/-catalog.

  case $vol in # Build the specified volume.
  
    # General process: mount the source, copy the files, dismount the source, pad the files, set datestamps, build 
    # ARK/LBR/DSK archives, and finally show the file CRCs. Reminder (cuz I'm always in danger of forgetting why): 
    # datefiles must run before archives so that files have proper dates before they're archived. 
  
    001) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    002) copyfiles cpmug    ;                         rename "./SIG_M.$vol ./-CATALOG.$vol"                                                    ; pad ; datefiles; archives; checkcrc ;;
    003) copyfiles oak      ; source wc; head -n 15 $src/../vol015/sigmlog.003 > $builddir/-CATALOG.$vol; tail -n 12 $src/../vol015/sigmlog.003 > $builddir/ABSTRACT.$vol; dismount; pad; datefiles; archives; checkcrc ;;
    004) copyfiles cpmug    ;                         rename "DU_8_12.ASM DU-8_12.ASM" "BDOS_PAT.ASM BDOS-PAT.ASM"                             ; pad ; datefiles; archives; checkcrc ;;
    005) copyfiles cpmug    ;                         rename "CP_M_NET.MSG CP_M-NET.MSG"                                                       ; pad ; datefiles; archives; checkcrc ;;
    006) copyfiles cpmug                                                                                                                       ; pad ; datefiles; archives; checkcrc ;;
    007) copyfiles nicholson                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    008) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    009) copyfiles nicholson                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    010) copyfiles nicholson                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    011) copyfiles cpmug                                                                                                                       ; pad ; datefiles; archives; checkcrc ;;
    012) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    013) copyfiles nicholson                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    014) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    015) copyfiles cpmug    ;                         rename "./-CATALOG.015  CATALOG.015" "DCATALOG.015 ./-CATALOG.015"                       ; pad ; datefiles; archives; checkcrc ;;
    016) copyfiles cpmdosgg ;                         rename "DU_*" "FILE_*"                                                                   ; pad ; datefiles; archives; checkcrc ;;
    017) copyfiles cpmdosgg ;                         rename "SORTV_*" "./_CATALOG.ACK ./-CATALOG.ACK"                                         ; pad ; datefiles; archives; checkcrc ;;
    018) copyfiles nicholson;                         rename "CATALOG.ACK  ./-CATALOG.ACK"                                                     ; pad ; datefiles; archives; checkcrc ;;
    019) copyfiles nicholson;                         rename "CATALOG.ACK ./-CATALOG.ACK"                                                      ; pad ; datefiles; archives; checkcrc ;; # CRCK.COM, SIG/M.LIB: in CRCKFILE.019 and on disk but not -CATALOG.019. CRCKFILE.019: in -CATALOG.019 and on disk but not in CRCKFILE.019
    020) copyfiles nicholson                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; # -CATALOG.020 CRC mismatch; CRCK.COM not listed in -CATALOG; CRCKFILE.020 not listed in CRCKFILE.
    021) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    022) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc  ; notes "TEST.DAT doesn't appear in the earliest source " "(CPMDOSgg) nor in -CATALOG or CRCKFILE. Removed." ;;
    023) copyfiles nicholson                                                                                                                   ; pad ; datefiles; archives; checkcrc  ; notes "DATE.DOC, CRCK.COM, SIG/M.LIB only in CRCKFILE." ;; # SIG_M.LIB in CRCKFILE, not in -CATALOG. CRCK.COM in CRCKFILE, not in -CATALOG. CRCKFILE in -CATALOG, not in CRCKFILE.
    024) copyfiles nicholson;                         rename "CATALOG.ACK ./-CATALOG.ACK"                                                      ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB appears only in CRCKFILE." ;;
    025) copyfiles nicholson;                         rename "CATALOG.ACK ./-CATALOG.ACK"                                                      ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB appears only in CRCKFILE." ;;
    026) copyfiles cpmdosgg ;                         rename "EL_*" "./_CATA026.ACK ./-CATA026.ACK"                                            ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM EBASIC.COM RUN.COM SCRAMBLE.* SIGM.LIB   " "XMASTER.FIL appear in CRCKFILE only.";;
    027) copyfiles cpmdosgg ;                         rename "./_CATA027.ACK ./-CATA027.ACK"                                                   ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    028) copyfiles cpmdosgg ;                         rename "LIFE_*" "NAME_*" "_CATA028.ACK ./-CATA028.ACK" "NAME-ADD.DOC NAME&ADD.DOC"       ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    029) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    030) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "-CATA031.ACK -CATALOG.031 CRCK.COM CRCKLIST.031   " "SIG_M.LIB listed in CRCKFILE only.          " ;;
    031) copyfiles nicholson;                         rename "CATA031.ACK ./-CATA031.ACK"                                                      ; pad ; datefiles; archives; checkcrc  ; notes "Only Nicholson yields fully matching CRCs.        " "CRCK.COM, SIG/M.LIB appear in CRCKFILE only." ;;
    032) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    033) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    034) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    035) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    036) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    037) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    038) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    039) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    040) copyfiles cpmdosgg ;                         rename " MENU_*" "RUN80_*" "VMAP_*"                                                      ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM SIG/M.LIB HOST.PRN in CRCKFILE only.     " ;;
    041) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM SIG_M.LIB CDOS.DOC in CRCKFILE only.     " ;;
    042) copyfiles cpmdosgg ;                         rename "HD_*"                                                                            ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    043) copyfiles oak                                                                                                                         ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    044) copyfiles cpmdosgg ;                         rename "DU_*" "SD_*"  "WASH_*"                                                           ; pad ; datefiles; archives; checkcrc  ; notes "-CATALOG.044 lists WASH-16.ASM but all known sour-" "ces have WASH-14.ASM. CRCK.COM in CRCKLIST only.  " ;;
    045) copyfiles cpmdosgg ;      remove READ.ME                                                                                              ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB appears in CRCKFILE only.               " ;; # README isn't in any file list, and is just a portion of DUNGEO.DOC in any case. Bye-bye.
    046) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB appears in CRCKFILE only.               " ;;
    047) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB appears in CRCKFILE only.               " ;;
    048) copyfiles cpmdosgg ;                         rename "CRCKLIST.043 CRCKLIST.048"                                                       ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB appears in CRCKFILE only.               " ;;
    049) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "Corruption in -CATALOG.049 makes it impossible to " "extract MDBSGETM.PLI's CRC.                       " "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    050) copyfiles cpmdosgg ;      rename "TALK_.LIB TALK@.LIB" "VOIC_.DOC VOIC@.DOC" "VOIC_.LIB VOIC@.LIB" "VOIC_EQU.LIB VOIC@EQU.LIB"        ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;; # _ replaces @ instead of /; need to account for this
    051) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    052) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    053) copyfiles cpmdosgg ;                            rename "X_UTIL.SAM X\$UTIL.SAM" "READ_ME.DOC READ-ME.DOC"                             ; pad ; datefiles; archives; checkcrc  ; notes "PRICES.DOC doesn't appear in -CATALOG's listings, " "but is mentioned in -CATALOG notes.               " ;; 
    054) copyfiles cpmdosgg ;                            rename "I_O_CAP.ADD I_O-CAP.ADD" "I_O_CAP.ASM I_O-CAP.ASM"                            ; pad ; datefiles; archives; checkcrc  ; notes "TTBOOT.ASM's the only file in the SIG/M collection" "whose corruption remains unresolved.             " ;;
    055) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    056) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    057) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;;
    058) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    059) source cpmdosgg; for f in $tempdir/cpm06/627/* ; do cp $f $builddir/$(basename $f | tr 'a-z' 'A-Z') >/dev/null 2>&1; done; dismount; copyfiles \
         oak "-CATALOG.059" SIG-M.LIB CRCK.COM; rename "_HISTORY.018 READ.ME" "SIG-M.LIB SIG_M.LIB" ; remove _CATALOG.* CRCKLIST.CRC CRCK4.COM ; pad ; datefiles; archives; checkcrc  ; notes "Huge thanks to Martin from comp.os.cpm for finding" "clean copies of these files in cpmdosgg.          " ;;     
    060) copyfiles cpmdosgg ; copyfiles oak SIG-M.LIB ; rename "*_*" "SQ-USQ15.DOC SQ_USQ15.DOC"                                               ; pad ; datefiles; archives; checkcrc  ; notes "Only cpmdosgg's RBBS22.DOC and RBSUTL22.ASC       " "match CRCs. However it lacks SIG/M.LIB, which     " "is pulled from OAK.        " ;;
    061) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;; 
    062) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;; 
    063) copyfiles cpmdosgg ;                         rename "NAD_*"                                                                           ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM not in -CATALOG. Removed.                " ;;
    064) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM, SIG/M.LIB appear in CRCKFILE only.      " ;; 
    065) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB appears in CRCKFILE only.               " ;; 
    066) copyfiles cpmdosgg ; copyfiles cpmdosgg ../1057/crck.com; sed -i 's:CMMMAND:COMMAND:g' $builddir/ZCPR_14.ASM; rename "ZCPR*" "SD_*"   ; pad ; datefiles; archives; checkcrc  ; notes "At some point after CRCs were generated, a single " "byte in ZCPR_14.ASM was altered. Changing it back " "restores the proper CRC.   "  "SIG/M.LIB appears in CRCKFILE only.               " ;;
    067) copyfiles cpmdosgg ; copyfiles cpmdosgg ../1057/crck.com                                                                              ; pad ; datefiles; archives; checkcrc  ; notes "SIG/M.LIB listed in CRCKFILE only.                " ;;
    068) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    069) copyfiles cpmdosgg ;                         rename "CUB__.DAT CUB++.DAT"                                                             ; pad ; datefiles; archives; checkcrc ;;
    070) copyfiles cpmdosgg ;                         rename "A_*" "STARTRE_.NBP STARTRE\$.NBP"                                                ; pad ; datefiles; archives; checkcrc ;;
    071) copyfiles cpmdosgg ; copyfiles cpmdosgg ../1057/crck.com                                                                              ; pad ; datefiles; archives; checkcrc  ; notes "CRCK.COM doesn't appear in the sources, but is    " "listed in -CATALOG. It is copied from vol 57.     " ;;
    072) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    073) copyfiles cpmdosgg ;                         rename "COMP_*" "PAGE_*" "VD*"                                                           ; pad ; datefiles; archives; checkcrc ;;
    074) copyfiles cpmdosgg ;                         rename "CLOCK_*"                                                                         ; pad ; datefiles; archives; checkcrc ;;
    075) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    076) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    077) copyfiles cpmdosgg ;                         rename "*CPR_*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    078) copyfiles cpmdosgg ;                         rename "*TALK1_*"                                                                        ; pad ; datefiles; archives; checkcrc ;;
    079) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    080) copyfiles cpmdosgg ; copyfiles oak PINUP82.CAL SIGHTRED.COM ; remove *.081 CONSTS.* COPY.* D*.* FF.* GE*.* IM*.* PP.* PR*.* SP*.* *.TEX TP.* TY*.* X*.*; pad; datefiles; archives; checkcrc  ; notes "Thanks to Martin in the comp.os.cpm forums for discovering" "compdosgg has the correct CRCs. But compdosgg has" "additional files that must be cleaned out." ;;
    081) copyfiles oak                                                                                                                         ; pad ; datefiles; archives; checkcrc ;;
    082) copyfiles oak      ;                         rename "ABSTRACT.081 ABSTRACT.082"                                                       ; pad ; datefiles; archives; checkcrc ;;
    083) copyfiles cpmdosgg ;                         rename "ICE_*.*"                                                                         ; pad ; datefiles; archives; checkcrc ;;
    084) copyfiles oak      ; copyfiles cpmdosgg entrbbs.bas ; rename "FINDP.ASM FIND+.ASM" "FINDP.COM FIND+.COM" "XSTAMP.ASM XSTAM+.ASM" "XSTAMP.COM XSTAM+.COM" "CRC CRC.COM" ; pad ; datefiles; archives; checkcrc ;;
    085) copyfiles cpmdosgg ; copyfiles oak SIGNS.COM RUNOFF.COM PASDIR.PAS REMOVECC.PAS TRIMCOLS.PAS XSUB.COM                                 ; pad ; datefiles; archives; checkcrc  ; notes "Must mix and match CPMDOSGG and OAK" "to complete a set of intact files." ;;
    086) copyfiles oak      ;      remove "U.COM";    rename "FAST2.COM _.COM"                                                                 ; pad ; datefiles; archives; checkcrc  ; notes "Both CPMDOSGG and OAK have U.COM" "which is not listed in -CATALOG." "It is retained for now." ;;
    087) copyfiles cpmdosgg ; copyfiles oak BDSCAT.AQL RATFOR.HLP ; rename "DISPLAY_.ASM DISPLAY+.ASM" "DISPLAY_.COM DISPLAY+.COM" "TYP_.ASM TYP+.ASM" "TYP_.COM TYP+.COM" "THIS_*"; datefiles; archives; checkcrc ; notes "BDSCAT.AQL, RATFOR.HLP CRC mismatch, so copies pulled from OAK." ;;
    088) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    089) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ;  notes "SYSLIBI.WS is on disk but not listed in -CATALOG." ;;
    090) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    091) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ;  notes "READ.ME is on disk but not listed in -CATALOG.   " ;;
    092) copyfiles cpmdosgg ; rename "LITL_ADA.ASM LITL-ADA.ASM" "LITL_ADA.DOC LITL-ADA.DOC" "LITL_ADA.PRN LITL-ADA.PRN" "RBBS_USE.DOC RBBS-USE.DOC" ; pad ; datefiles; archives; checkcrc ;;
    093) copyfiles cpmdosgg ; copyfiles oak trsmodem.com ; copyfiles cpmdosgg ../1091/sig_m.lib                                                ; pad ; datefiles; archives; checkcrc ;;
    094) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    095) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    096) copyfiles cpmdosgg ;                         rename "CRCK_51.A86 CRCK-51.A86" "FILE_EXT.A86 FILE-EXT.A86" "XDIR_A86.DOC XDIR-A86.DOC" ; pad ; datefiles; archives; checkcrc ;;
    097) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    098) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "SYSIO.ASM is not listed in -CATALOG.              " ;;
    099) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    100) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    101) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    102) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    103) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    104) copyfiles oak      ; copyfiles oak sig/m.lib; rename "M.LIB SIG_M.LIB"                                                                ; pad ; datefiles; archives; checkcrc  ; notes "I don't know where the CRC compare value is from. I" "don't know if ZCPR2.IDX is correct." ;;
    105) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    106) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    107) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    108) copyfiles cpmdosgg ; copyfiles cpmdosgg ../../cpm11/1107/crc.com ; rename "Z2SYS_1.MOD Z2SYS-1.MOD"                                   ; pad ; datefiles; archives; checkcrc ;;
    109) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "-CATALOG seems to have omitted USERMAN2.TXT from its listing." ;;
    110) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc  ; notes "SIGN_ON.ACG, TWO_REC.FMT not listed in -CATALOG." ;;
    111) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    112) copyfiles cpmdosgg ;                         rename "*_*" "RBBS-I-O.NQW RBBS-I_O.NQW"                                                 ; pad ; datefiles; archives; checkcrc ;;
    113) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    114) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    115) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    116) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    117) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "USQ.COM not listed in -CATALOG." ;;
    118) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    119) copyfiles cpmdosgg ; copyfiles cpmdosgg ../../cpm11/1107/crc.com                                                                      ; pad ; datefiles; archives; checkcrc ;;
    120) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    121) copyfiles cpmdosgg ;                         rename "MDM709C_.AQM MDM709C+.AQM" "SD_*.*"                                              ; pad ; datefiles; archives; checkcrc ;;
    122) copyfiles cpmdosgg ;                         rename "DU2_*" "./ZCPR2.IDX ./-ZCPR2.IDX"                                                ; pad ; datefiles; archives; checkcrc ;;
    123) copyfiles cpmdosgg ;                         rename "FIND_*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    124) copyfiles cpmdosgg ;                         rename "ZCPR2_*"                                                                         ; pad ; datefiles; archives; checkcrc ;;
    125) copyfiles cpmdosgg ;    remove __SIG_M.125 ; rename "ZCPR2_*"                                                                         ; pad ; datefiles; archives; checkcrc ;;
    126) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    127) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    128) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    129) copyfiles oak      ; copyfiles oak db2sig/m.lbr; remove CRCKLIST.CRC; rename "M.LBR DB2SIG_M.LBR"                                     ; pad ; datefiles; archives; checkcrc  ; notes "CPMDOSGG seems an earlier version of SIG/M. -CATALOG" "lists DB2SIG/M.LBR (0E47), but the disk holds instead" "its expanded contents. OTOH, OAK/WC have DB2SIG/M.LBR" "(51C0) & matching -CATALOGs. No known extant ver of" "(0E47). Compares of CPMDOSGG files w/OAK LBR contents" "reveals significant CRC differences. I've chosen to" "go with OAK for this volume." ;;
    130) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    131) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    132) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    133) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "ABSTRACT.133 listed in -CATALOG but is missing in" "all extant sources." ;;
    134) copyfiles cpmdosgg ;                         rename "GLOBALS.RN_ GLOBALS.RN$" "PASZCODE.RN_ PASZCODE.RN$"                             ; pad ; datefiles; archives; checkcrc ;;
    135) copyfiles cpmdosgg ;                         rename "DIR_*"                                                                           ; pad ; datefiles; archives; checkcrc  ; notes "TEST.SUB not in -CATALOG." ;;
    136) copyfiles cpmdosgg ;                         rename "BB_*.*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    137) copyfiles cpmdosgg ;                         rename "MP_*"                     ; touch $builddir/MP-SIMUL.IN2                         ; pad ; datefiles; archives; checkcrc  ; notes "-CATALOG lists a 0-byte MP-SIMUL.IN2, which is miss-" "ing from some collections. It is recreated here." ;;
    138) copyfiles cpmdosgg ;                         rename "MP_DEMO.LBR MP-DEMO.LBR"                                                         ; pad ; datefiles; archives; checkcrc ;;
    139) copyfiles cpmdosgg ;                         rename "UN_PROT.BAS UN-PROT.BAS"                                                         ; pad ; datefiles; archives; checkcrc ;;
    140) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    141) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    142) copyfiles cpmdosgg ;                         rename "*_*" "SFA-SAV.0 SFA_SAV.0"                                                       ; pad ; datefiles; archives; checkcrc ;;
    143) copyfiles cpmdosgg ;                         rename "PACKET_*"                                                                        ; pad ; datefiles; archives; checkcrc ;;
    144) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    145) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    146) copyfiles cpmdosgg ;                         rename "SD_48B.A86 SD-48B.A86" "SD_48B.CMD SD-48B.CMD"                                   ; pad ; datefiles; archives; checkcrc ;;
    147) copyfiles cpmdosgg ; vol=144; copyfiles cpmdosgg usq.com; vol=147; rename "FILE_*" "CRCK_*" "WM_*"                                    ; pad ; datefiles; archives; checkcrc ;;
    149) copyfiles cpmdosgg ;                         rename "MODEM7_*" "UNIX_*"                                                               ; pad ; datefiles; archives; checkcrc ;;
    148) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    150) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    151) copyfiles cpmdosgg ;                         rename "DSK7_*" "MBOOT_*" "FMT_*" "MODEM_*"                                              ; pad ; datefiles; archives; checkcrc ;;
    152) copyfiles cpmdosgg ;                         rename "DU_*.*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    153) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    154) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    155) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "ABSTRACT.155 is missing from all collections." ;;
    156) copyfiles cpmdosgg ;                         rename "SQ_*"                                                                            ; pad ; datefiles; archives; checkcrc ;;
    157) copyfiles cpmdosgg ;                         rename "Z80_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    158) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    160) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    159) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    161) copyfiles cpmdosgg ;                         rename "DU_*" "TYPER_*"                                                                  ; pad ; datefiles; archives; checkcrc ;;
    162) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    163) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    164) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "READTHIS not in -CATALOG." ;;
    165) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "READTHIS not in -CATALOG." ;;
    166) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "READTHIS not in -CATALOG." ;;
    167) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    168) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc  ; notes "READTHIS not in -CATALOG." ;;
    169) copyfiles cpmdosgg ;                         rename "M7*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    170) copyfiles cpmdosgg ;                         rename "M7*" "M7AC-3.AQM M7AC+3.AQM"                                                     ; pad ; datefiles; archives; checkcrc ;;
    171) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    172) copyfiles cpmdosgg ; copyfiles sourdough disk3.asm; unix2dos $builddir/DISK3.ASM>/dev/null 2>&1; rename "DU_*" "OKI_*"                ; pad ; datefiles; archives; checkcrc ;;
    173) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    174) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    175) copyfiles cpmdosgg ;                         rename "F47_*" "MODEM_*"                                                                 ; pad ; datefiles; archives; checkcrc ;;
    176) copyfiles cpmdosgg ;                         rename "DRI_*" "DU_*" "SD_*"                                                             ; pad ; datefiles; archives; checkcrc ;;
    177) copyfiles cpmdosgg ;                         rename "MY_*"; for i in $builddir/WS_*; do mv $i $(echo $i | tr '_' '$'); done           ; pad ; datefiles; archives; checkcrc ;;
    178) copyfiles cpmdosgg ; vol=177; copyfiles cpmdosgg sig_m.lib; vol=178                                                                   ; pad ; datefiles; archives; checkcrc ;;
    179) copyfiles cpmdosgg ;                         rename "BIOS3_.DQC BIOS3+.DQC"                                                           ; pad ; datefiles; archives; checkcrc  ; notes "CARCHIVE.DQC not listed in -CATALOG." ;;
    180) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    181) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc  ; notes "CXREF.HQP not listed in -CATALOG. File indices in -CATALOG.182 are messed up; fixed in rebuild." ;;
    182) copyfiles cpmdosgg ;                         rename "NS_*" "TAG_*"                                                                    ; pad ; datefiles; archives; checkcrc ;;
    183) copyfiles cpmdosgg ;                         rename "READ_*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    184) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    185) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    186) copyfiles cpmdosgg ;                         rename "CRC_*"                                                                           ; pad ; datefiles; archives; checkcrc ;; 
    187) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    188) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    189) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    190) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    191) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    192) copyfiles cpmdosgg ;                         rename "SYS2*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    193) copyfiles cpmdosgg ;                         rename "PAF*"                                                                            ; pad ; datefiles; archives; checkcrc ;;
    194) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    195) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "-CATALOG mis-lists DELBR.COM as DELRB.COM." ;;
    196) copyfiles cpmdosgg ;                         rename "SD_*"                                                                            ; pad ; datefiles; archives; checkcrc ;;
    197) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "-CATALOG mis-lists DELBR.COM as DELIB.COM." ;;
    198) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    199) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    200) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    201) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    202) copyfiles cpmdosgg ;                         rename "RSA_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    203) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    204) copyfiles cpmdosgg ;                         rename "F83_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    205) copyfiles cpmdosgg ;                         rename "F83_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    206) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    207) copyfiles cpmdosgg ; vol=205; copyfiles cpmdosgg sig_m.lib; vol=207; rename "LU86_*" "APC_DUMP.LBR APC-DUMP.LBR"                      ; pad ; datefiles; archives; checkcrc ;;
    208) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    209) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    210) copyfiles cpmdosgg ;                         rename "CRC_64.AQ6 CRC-64.AQ6"                                                           ; pad ; datefiles; archives; checkcrc ;;
    211) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    212) copyfiles cpmdosgg ;                         rename "CPM2__.LBR CPM2-+.LBR" "FIND_2.LBR FIND+2.LBR" "UNERA_.LBR UNERA+.LBR" "*_*"     ; pad ; datefiles; archives; checkcrc ;;
    213) copyfiles cpmdosgg ;                         rename "LBR_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    214) copyfiles cpmdosgg ;                         rename "LBR_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    215) copyfiles cpmdosgg ;                         rename "LBR_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    216) copyfiles cpmdosgg ;                         rename "M8NM_*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    217) copyfiles cpmdosgg ;                         rename "M8??_*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    218) copyfiles cpmdosgg ;                         rename "MX?_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    219) copyfiles cpmdosgg ;                         rename "MX?_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    220) copyfiles cpmdosgg ;                         rename "MX?_*" "MXO-R-10.AQM MXO-R+10.AQM"                                               ; pad ; datefiles; archives; checkcrc ;;
    221) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    222) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    223) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    224) copyfiles cpmdosgg ;                         rename "C80V_*"                                                                          ; pad ; datefiles; archives; checkcrc ;;
    225) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    226) copyfiles cpmdosgg ;                         rename "DRI_*"                                                                           ; pad ; datefiles; archives; checkcrc ;;
    227) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    228) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    229) copyfiles cpmdosgg ;                         rename "SAVE0_*" "APC_*"                                                                 ; pad ; datefiles; archives; checkcrc ;;
    230) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    231) copyfiles cpmdosgg ;                         rename "CP_M_.LBR CP-M+.LBR"                                                             ; pad ; datefiles; archives; checkcrc ;;
    232) copyfiles cpmdosgg ;                         rename "M7BBS_.AQM M7BBS+.AQM"                                                           ; pad ; datefiles; archives; checkcrc ;;
    233) copyfiles cpmdosgg ;                         rename "BOY_*"                                                                           ; pad ; datefiles; archives; checkcrc  ; notes "CLEANUP.DQC not listed in -CATALOG." ;;
    234) copyfiles cpmdosgg ; vol=233; copyfiles cpmdosgg crc.com; vol=234                                                                     ; pad ; datefiles; archives; checkcrc ;;
    235) copyfiles cpmdosgg ; vol=234; copyfiles cpmdosgg usq.com; vol=235; rename "BOKA_EI.BQS BOKA&EI.BQS" "FORTH_*"                         ; pad ; datefiles; archives; checkcrc ;;
    236) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    237) copyfiles cpmdosgg ;                         rename "PILOT_*"                                                                         ; pad ; datefiles; archives; checkcrc ;;
    238) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    239) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    240) copyfiles cpmdosgg ;                         rename "DELBR.COM DELBRA.COM"                                                            ; pad ; datefiles; archives; checkcrc  ; notes "EPRINT.ZSM is unlisted in -CATALOG." ;;
    241) copyfiles cpmdosgg ;                         rename "DELBR.COM DELBRA.COM"                                                            ; pad ; datefiles; archives; checkcrc ;;
    242) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    243) copyfiles oak      ; unix2dos $builddir/VISCOS1.DAT>/dev/null 2>&1; unix2dos $builddir/GETNAME.PRO>/dev/null 2>&1                     ; pad ; datefiles; archives; checkcrc ;; 
    244) copyfiles cpmdosgg ;                         rename "LPAK1?_*"                                                                        ; pad ; datefiles; archives; checkcrc ;;
    245) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    246) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    247) copyfiles cpmdosgg ;                         rename "DU_*" "Z19_*"                                                                    ; pad ; datefiles; archives; checkcrc ;;
    248) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    249) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    250) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc  ; notes "Though VDO25.LBR is not listed in -CATALOG" "and seems out of place, it is retained.    " ;;
    251) copyfiles cpmdosgg ; vol=250; copyfiles cpmdosgg usq.com; vol=251; rename "DELBR.COM DELBRA.COM"                                      ; pad ; datefiles; archives; checkcrc ;;
    252) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    253) copyfiles oak                                                                                                                         ; pad ; datefiles; archives; checkcrc ;; 
    254) copyfiles cpmdosgg ;                         rename "DELBR.COM DELBRA.COM"                                                            ; pad ; datefiles; archives; checkcrc ;;
    255) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    256) copyfiles cpmdosgg ;                         rename "TFR_*" "TRANS_*"                                                                 ; pad ; datefiles; archives; checkcrc ;;
    257) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    258) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    259) copyfiles oak                                                                                                                         ; pad ; datefiles; archives; checkcrc ;;
    260) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    261) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    262) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    263) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    264) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    265) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    266) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    267) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    268) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    269) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;; 
    270) copyfiles cpmdosgg ;                         rename "FS_*"                                                                            ; pad ; datefiles; archives; checkcrc ;;
    271) copyfiles cpmdosgg ;                         rename "FP_*"                                                                            ; pad ; datefiles; archives; checkcrc ;;
    272) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    273) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    274) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    275) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    276) copyfiles cpmdosgg ;                         rename "*_*"                                                                             ; pad ; datefiles; archives; checkcrc ;;
    277) copyfiles cpmdosgg                                                                                                                    ; pad ; datefiles; archives; checkcrc ;;
    278) copyfiles oak                                                                                                                         ; pad ; datefiles; archives; checkcrc ;; 
    279) copyfiles oak      ; copyfiles cpmdosgg comp.asm label.mac tail.asm                                                                   ; pad ; datefiles; archives; checkcrc ;;
    280) copyfiles oak      ; unix2dos $builddir/MULTCOL.PAS>/dev/null 2>&1                                                                    ; pad ; datefiles; archives; checkcrc ;;
    281) copyfiles sourdough; for i in CMPCODE.DOC SNOOPY.FOR ZLOAD.DOC FORT07.DAT; do unix2dos $builddir/$i>/dev/null 2>&1; done              ; pad ; datefiles; archives; checkcrc ;;
    282) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    283) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    284) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    285) copyfiles sourdough                                                                                                         ; padnull ; pad ; datefiles; archives; checkcrc ;; 
    286) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    287) copyfiles sourdough; copyfiles sourdough ../vol286/usq.com                                                                            ; pad ; datefiles; archives; checkcrc ;; 
    288) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    289) copyfiles sourdough; unix2dos $builddir/RAMDSKRB.DOC>/dev/null 2>&1                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    290) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    291) copyfiles sourdough; x=../../../library_collections/dka_kaypro/900/913; copyfiles sourdough $x/CLOCK.LIB $x/CONCORD.PAS $x/DELIB.PAS $x/DIR.INC $x/DWS.PAS \
         $x/ERRORS.PAS $x/FREEDIR.INC $x/FREE.INC $x/FUNCKEYS.PAS $x/IOERROR.PAS $x/../914/MLABELS.PAS $x/../914/OKI.PAS ../vol293/wipe.pas    ; pad ; datefiles; archives; checkcrc ;; 
    292) copyfiles sourdough; x=../../../library_collections/dka_kaypro/900/914; copyfiles sourdough $x/SIZE.PAS $x/STRIP8.PAS                 ; pad ; datefiles; archives; checkcrc ;; 
    293) copyfiles sourdough; remove WIPE.PAS                                                                                                  ; pad ; datefiles; archives; checkcrc  ; notes "WIPE.PAS not listed in -CATALOG. Identical to v291" "WIPE.PAS, so removed here." ;;
    294) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    295) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    296) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    297) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    298) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    299) copyfiles sourdough;                         rename "KPHANDYP.LBR KPHANDY+.LBR"                                                       ; pad ; datefiles; archives; checkcrc  ; notes "-READ.ME not listed in -CATALOG." ;;
    300) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    301) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;; 
    302) copyfiles sourdough;                         remove CRCKLIST.CRC                                                                      ; pad ; datefiles; archives; checkcrc ;; 
    303) copyfiles sourdough; vol=294; copyfiles sourdough crc.com; vol=303                                                                    ; pad ; datefiles; archives; checkcrc ;;
    304) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    305) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    306) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    307) copyfiles sourdough;      remove ./-READ.ME; rename "RDIR15P.LBR RDIR15+.LBR"                                                         ; pad ; datefiles; archives; checkcrc ;;
    308) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    309) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
    310) copyfiles sourdough                                                                                                                   ; pad ; datefiles; archives; checkcrc ;;
      *) echo Volume $vol not implemented yet. ;;                                      # You should never see this.
  esac
  
#---------
# Clean up
#---------
  [[ -d $tempdir ]] && rm -rf $tempdir                                                 # in case it somehow got missed.
  cd - >/dev/null 2>&1
exit 0
