#!/usr/bin/perl -w
use strict;
use warnings;
use File::Copy;
my $usage=<<USAGE;
Usage:
perl dz_putFiles2oneDir.pl /path/to/input_dir /path/to/filename
USAGE
if(@ARGV==0){die $usage};
my $file1=$ARGV[0];
my $file2=$ARGV[1];
my $input_dir=$file1;
my $output=$file2;
opendir(DIR,$input_dir) || die "can not open the directory";
if(!(-d $output)){
mkdir ($output); #创建文件夹
}
if((-d $input_dir) && ($input_dir ne $output)){
my @files=glob($input_dir."/*/*.gz");
for my $i (0..$#files){
copy ($files[$i],$output) || die "Copy failed: $!";
}
}
closedir(DIR);