#!/usr/bin/perl
$list_file = "list2.txt";
$HOME_dir = `echo \$HOME`;
chomp $HOME_dir; #刪去換行符
$pic_dir = $HOME_dir."/magic/dir/";
$dst_dir = $HOME_dir."/Desktop/tmp/"; #目的路徑
sub test_tmp_dir {
    mkdir($dst_dir) unless (-d $dst_dir);
}
$f_str = "find $pic_dir -type f | sed 's#.*/##' | grep -F -f $list_file";
@f =  `$f_str`;
chomp @f;
test_tmp_dir();
foreach (@f) {
    print "$_\n";
    $fn = "find $pic_dir -name \"$_\" -exec cp {} $dst_dir \\;";
    system($fn);
}
$command = "find $pic_dir -type f | wc -l";
$count = `$command`;
print "Total find files:$count\n";
