1234567890x.las 1234567890x1.las 1234567890x2.las #### #!/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; } #### #!/usr/bin/perl -w use strict; my $loc_dir = 'h:/andrew/bruner/temp/stage/'; my $to_dir = 'h:/andrew/bruner/temp/stage/copies/'; my $net_dir = 'j:/templas/'; my $from = '.las'; my $counter = '0'; my ($old, $new, $name); my @usedarray; while (<$loc_dir*$from>) { $old = $new = $_; $new =~ s/^$loc_dir/$net_dir/; while (exist($new)) { $counter++; $new = substr($new, 0, 22) . $counter . ".las"; } $counter = '0'; $new =~ s/^$net_dir/$to_dir/; rename $old, $new; print "\nRenamed $old $new"; } sub exist { my $file = shift; if (-e $file) { print "\nFile $file exists."; return 1; } $file =~ s/^$net_dir/$to_dir/; if (-e $file) { print "\nFile $file exists."; return 1; } } #### my @files2 = glob("$dir2/*.las"); #### while (<$loc_dir*$from>) {