use warnings;
use strict;
use File::Copy;
use File::Glob ':glob';
mkdir 'test' unless -d 'test';
#foreach( reverse sort glob( "*_Table_*.pdf" ) ){
foreach( sort glob( "*_Table_*.pdf" ) ){
print "$_\n";
my $newname = $_;
$newname =~ s/^[0-9_]+//;
print "--$newname\n";
## using copy for testing.
copy $_, "./test/$newname" or print "Error copying <$_> $!\n";
#move $_, "$newname" or print "Error renaming <$_> $!\n";
}
__DATA__
test files:
8_2007_5_22_15_34_23_Table_-_2007522_XYZ_W3.pdf
8_2007_5_22_22_34_12_Table_-_2007522_XYZ_W3.pdf
7_2007_5_22_16_35_23_Table_-_2007522_XYZ_W3.pdf
7_2007_5_22_23_36_12_Table_-_2007522_XYZ_W3.pdf
output file:
Table_-_2007522_XYZ_W3.pdf
####
8_2007_5_22_22_34_12_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf
8_2007_5_22_15_34_23_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf
7_2007_5_22_22_34_12_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf
7_2007_5_22_15_34_23_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf
7_2007_12_22_15_34_23_Table_-_20071222_XYZ_W3.pdf
--Table_-_20071222_XYZ_W3.pdf
##
##
7_2007_12_22_15_34_23_Table_-_20071222_XYZ_W3.pdf
--Table_-_20071222_XYZ_W3.pdf
7_2007_5_22_15_34_23_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf
7_2007_5_22_22_34_12_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf
8_2007_5_22_15_34_23_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf
8_2007_5_22_22_34_12_Table_-_2007522_XYZ_W3.pdf
--Table_-_2007522_XYZ_W3.pdf