#!/usr/bin/perl # Routine to check for the existence of all files listed in a volume index. # # Format: % check_index -i -o offset -l length index_file report_file # # -i = ignore missing data files # -s = start byte of file name # -l = length of file name field # # This routine may be run from anywhere. # # 02 Feb 2006, ACR. # #============================================================================ $VID = "nreros_2001"; $VOLROOT = "/n/pdsraid02/volume"; $CUMINDEX = "$VOLROOT/$VID/index/index.tab"; $OUTFILE = "$VID.rpt"; $READ_VID = 0; $vol = "$VID"; $voff = 44; $vlen = 11; $FULL_PATH = 0; $poff = 1; $plen = 15; $foff = 20; $flen = 17; $noff = 58; $nlen = 19; # First, open the files: open (IDX,$CUMINDEX) || die "Could not open $CUMINDEX ($!)"; open (OUT,">$OUTFILE") || die "Could not open $OUTFILE ($!)"; printf OUT "Missing files: \n"; $missing_count = 0; $no_data = 0; # Now we loop: while ($line=) { if ($READ_VID) { $vol = substr($line,$voff,$vlen); $vol =~ tr/A-Z/a-z/; } if ($FULL_PATH) { $label = substr($line,$noff,$nlen); } else { $label = substr($line,$poff,$plen) . "/" . substr($line,$foff,$flen); } $label =~ tr/A-Z/a-z/; $label =~ s/\s+//g; # Assemble the label file name and check for existence: $file = "$VOLROOT/$vol/$label"; if (! -e $file) { printf OUT " $vol/$label\n"; $missing_count++; next; } # If it's a detached label file (ends in ".lbl"), check for a ".fit" or # ".tab" file to go with it: if ((! $opt_i) && ($file =~ /\.lbl/)) { $fit = $file; $fit =~ s/\.lbl/.fit/; $tab = $file; $tab =~ s/\.lbl/\.tab/; if ((! -e $fit) && (! -e $tab)) { printf OUT " $file ....... NO DATA FILE?\n"; $no_data++; } } # Next. } # Report totals, close up files and we're done: close(IDX); #printf STDOUT "\n$missing_count Missing label files; $no_data ? data files\n"; printf OUT "\n$missing_count Missing label files; $no_data ? data files\n"; close(OUT);