I am using the below script to rename but it is renaming the all file end with STA.I need to rename the file that starts with KRAT or TRAT.
#!/usr/local/bin/perl
use strict;
use warnings;
use File::Copy;
my $directory = 'C:\Users\Desktop';
chdir($directory) or die "Can't chdir to $directory $!";
opendir(DIR, $directory) || die "Couldn't opendir: $!\n";
my @files = grep { $_ ne '.' && $_ ne '..' } readdir DIR;
foreach(@files) {
print $_,"\n";
my $newName = $_;
$newName =~ s/STA$/t00/g;
print "RENAMING: $_ -> $newName \n";
rename($_, $newName);
}