Hey all, lets say I have a directory that contains the following files
I want to get a list of all the files that begin with test and have a _number and rename them. I want to rename them to test_number + 1. I have created a script that is not working, it is a regexp.
any help with the regexp would be grateful.
Thanks,
timgerr
-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!
Code:
test
test_1
test_22
test_200
test_301
test_555
testing
wasatest
sysconfig
test.cfg
htp.conf
Code:
#!/usr/bin/perl
use Cwd;
use File::Copy;
# We have to get the argumet
my $fileToName = $ARGV[0];
chomp($fileToName);
my $dir = getcwd;
my $dirToOpen = $dir;
opendir(DIR,$dir) || die("Cannot open directory !\n");
@dirContents = readdir(DIR);
closedir(DIR);
foreach $file (@dirContents)
{
if(!(($file eq ".") || ($file eq "..")))
{
if($fileToName =~ /$file\d/){
print $file . "\n";
}
}
}
any help with the regexp would be grateful.
Thanks,
timgerr
-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!