#!perl
#
#
# Make a file of Tex tags for table elements.
#
# Modification history:
# 24 Aug 2005  TA  Written

use strict;
use warnings;
use File::Copy;
use Data::Dumper;

my $prefix;

if (-d "../compositelinks/trunk/vectfiles/tight/") {

  $prefix = "../compositelinks/trunk/vectfiles/tight/";

} elsif (-d "../compositelinks/vectfiles/tight/") {
  
  $prefix = "../compositelinks/vectfiles/tight/";

}

my $crnum;

foreach $crnum (6..12) {

  my $dir = $prefix.$crnum;
  my @vectfiles = <$dir/*.vect>;

  print "Found ".scalar @vectfiles." files for $crnum crossing composites in $dir.\n";
  print "Converting names to standard form...\n";

  my $thisfile;
  foreach $thisfile (@vectfiles) {

    my $newname;
    my $regdir;

    $regdir = quotemeta($dir);

    $newname = $thisfile;
    $newname =~ s/.vect//g; # Take out the .vect suffix.
    $newname =~ tr/[\.]/[\_]/; # convert all dots to underscores
    $newname = $newname.".vect"; # stick the vect back on

    my @splitversion;
    @splitversion = split(/\//,$newname);
    $newname = @splitversion[$#splitversion];

    $newname = "./compositevects/".$newname;

    unless (-f $newname) {

      print "$thisfile -> $newname\n";
      copy($thisfile,$newname) or die("Couldn't copy $thisfile -> $newname.\n");

    }

  }

}

    


# #open(DB,'KnotDB.pl');
# my $DBFILE = read_file('KnotDB.pl');
# my %knots;

# eval($DBFILE);

# #close(DB);

# my $numkeys = keys ( %knots );
# print "We have $numkeys entries in the original database. Looking for knots.\n";

# # first, a pass to remove files from the hash

# my $key;

# foreach $key ( sort(keys %knots) ) {

#     if ($key =~ /.vect/) {

# 	delete $knots{$key};

#     }

# }



