#!/usr/bin/perl # # This script renames NEAR MSI sumfiles to remove extra characters # after the image MET. Input is a sumfile directory. Renaming # is done in place. This was used to remove the extra letter # from the sumfiles Olivier gave me for the MSI PDS backplanes # delivery (the letter was the filter wheel number as a letter). # # Sample directory contents # M0125990473E.SUM # M0156106919H.SUM # ... # # Directory contents after script execution: # M0125990473.SUM # M0156106919.SUM # ... # # Note that duplicates will be overwritten in alphanumeric sort order # e.g. M0123456789E.SUM and M0123456789Q.SUM will both be written to # M0123456789.SUM but the contents will be from M0123456789Q.SUM # since it appears last in the sort order. This will not be an issue # as there cannot be duplicates (there can't be two images taken with # different filter wheels at the same image MET). # use Cwd; # # SUM_DIR contains ALL of the sumfiles, given to me by email from Olivier on 9/27/16. # All will be delivered rather than just the ~20K images used in the Eros shape v1. # They are registered to the newer version shape model, not the version 1 archived # at PDS. Olivier claims they are nearly identical and can be used interchangeably. # Olivier's original archive is in # /project/sbmtpipeline/rawdata/near/sumfilesFromOlivierForAllImagesPDSDelivery/sumfiles_to_be_delivered.tar.gz # my $SUM_DIR="/project/nearsdc/data/GASKELL/EROS/MSI/sumfiles_to_be_delivered/"; #my $SUM_DIR="/homes/nguyel1/tests/shell/renameFiles"; chdir ("$SUM_DIR") or die "Cant chdir to $SUM_DIR $!"; my $cwd = getcwd(); print "\n", cwd(); foreach $SUMFILE (glob("*.SUM")) { $RENAMED = substr($SUMFILE,0,11).".SUM"; print "Changing $SUMFILE to $RENAMED\n"; rename($SUMFILE,$RENAMED); }