Perl renameBamFile.pl

From ZhangLabWiki
Jump to navigation Jump to search
#!/usr/bin/perl
use strict;
use Cwd;
chdir getcwd;
my @file=glob("*.bam");
foreach my $file(@file){
       my($sample,undef)=split /_val_1|_trimmed|.read1|.bam/,$file;
       system("mv $file $sample.bam");
       print "mv $file $sample.bam\n";
}