• Source
    1. #!/usr/bin/perl
    2. $list_file = "list2.txt";
    3. $HOME_dir = `echo \$HOME`;
    4. chomp $HOME_dir; #刪去換行符
    5. $pic_dir = $HOME_dir."/magic/dir/";
    6. $dst_dir = $HOME_dir."/Desktop/tmp/"; #目的路徑
    7. sub test_tmp_dir {
    8. mkdir($dst_dir) unless (-d $dst_dir);
    9. }
    10. $f_str = "find $pic_dir -type f | sed 's#.*/##' | grep -F -f $list_file";
    11. @f = `$f_str`;
    12. chomp @f;
    13. test_tmp_dir();
    14. foreach (@f) {
    15. print "$_\n";
    16. $fn = "find $pic_dir -name \"$_\" -exec cp {} $dst_dir \\;";
    17. system($fn);
    18. }
    19. $command = "find $pic_dir -type f | wc -l";
    20. $count = `$command`;
    21. print "Total find files:$count\n";
    22.