#!/usr/bin/perl #------------------------------------------------------------------------------ #This PERL script makes one big list for all the files found under the user supplied #directory. #Written by Matthew McCready #-------------------------------------------------------------------------- use Getopt::Long; use File::Copy; use lib "/home/m/mccre004/File-Recurse-0.11/blib/lib"; use File::Recurse; sub usage() { print "Usage: $0 [-directory=]\n"; print "Example:perl $0 -directory=/usr/directory\n"; print " where /usr/directory is the directory where the .xml files to"; print " be listed are located.\n"; } %gOptions; &GetOptions(\%gOptions, qw(directory=s) ); unless ($gOptions{directory}) { usage(); exit(1); }; #Infile = $gOptions{listfile}; $directory=$gOptions{directory}; chdir $directory; opendir INDIR, $directory; foreach $file (readdir INDIR){ $dotLocation=index($file,"."); $preDot= substr($file,0,$dotLocation); $postDot=substr($file,$dotLocation); $newISO= $preDot . "_newISO" . $postDot; print "\$file = $file\n"; #print "\$preDot = $preDot\n"; #print "\$postDot = $postDot\n"; #print "\$newISO = $newISO\n"; open INFILE, "<$file"; open OUTFILE,">$newISO"; while (){ $line =$_; #print "\$line = $line\n"; if ($line =~ / Current Block Group State-based<\/gco:CharacterString>/){#change for every theme!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if ($line =~ /Series Information/){ print OUTFILE "$line"; }elsif($line =~ /Feature Catalog/){ print OUTFILE "$line"; }else{ $foundTheme="yes"; $newLine=$line; }; }elsif($foundTheme eq "yes"){ print OUTFILE "$newLine"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " "; print OUTFILE "National Geospatial Data Asset (NGDA) Current Block Group State-based Shapefile";#---------------------Change for every theme!!!!!!!!!!!!!!!!!!!!!!! print OUTFILE " \n"; print OUTFILE " \n"; $foundTheme="no"; }elsif($line =~ /Governmental Units, and Administrative and/){ print OUTFILE " Governmental Units and Administrative and Statistical Boundaries Theme\n";#Make sure that this is the right theme!!!!!!!!!!! }elsif($line =~ /Statistical Boundaries<\/gco:CharacterString>/){ #nothing }elsif($line =~ / NGDA Portfolio Themes/){ print OUTFILE " National Geospatial Data Asset"; }elsif($line =~ / ngda<\/gco:CharacterString>/){ print OUTFILE " NGDA<\/gco:CharacterString>\n"; }else{ print OUTFILE "$line"; }; #close OUTFILE; #close INFILE; }; close OUTFILE; close INFILE; system "mv $newISO $file"; system "rm $newISO"; };