use File::Copy; mkdir 'WEIGHT' or die $!; for my $file (glob 'ID_*_weight.txt') { copy($file, 'WEIGHT') or die $!; }