#!/usr/bin/perl -w use strict; my $dir1 = "h:/andrew/bruner/temp/stage/copies"; my $dir2 = "j:/templas"; my $field1 = " "; my $field2 = " "; my $testflag = '0'; my $newname = " "; my $oldname = " "; my $counter = '0'; print "\nGlobbing 1st set..."; my @files1 = glob("$dir1/*.las"); print "done\nGlobbing 2nd set..."; my @files2 = glob("$dir2/*.las"); print "done.\n"; foreach $field1 (@files1) { $testflag = '1'; $oldname = $field1; while ($testflag == '1') { foreach $field2 (@files2) { if (substr($field1, 35, 11) eq substr($field2, 11, 11)) { $counter++; $field1 = substr($field1, 0, 46) . $counter . ".las"; print "Trying $field1\n"; } else { $testflag = '0'; } } } if ($counter >= '1') { $newname = substr($field1, 0, 46) . $counter . ".las"; } else { $newname = substr($field1, 0, 46) . ".las"; } push (@files2, $newname); rename $oldname, $newname; print "$oldname renamed to $newname"; $counter = 0; }