#!/usr/bin/perl
use File::Find;
use File::Copy;
use File::Basename;
$HOME_dir = `echo \$HOME`;
$dst_dir = $HOME_dir."/Desktop/tmp/"; #目的路徑
$pic_dir = $HOME_dir."/magic/dir"; #圖片檔目錄
$filename = "list2.txt";
#-- 遞迴找檔案 --
sub find_file {
$dir = $File::Find::dir;
$fname = $File::Find::name;
$name = $_;
$basename = fileparse($fname, qr/\..*/);
next if ($name =~ /^\./);
next if (-d $name);
$num = $basename;
$newfile = $dst_dir.$name;
if (-d $dst_dir) {
copy ($fname, $newfile);
} else {
copy ($fname, $newfile);
}
}
} #sub END
sub print_hash_data {
print "-----Print HASH Data-----\n"; while(($key, $value) = each %HASH) { print "$key => $value\n"; }
}
sub print_file_count {
$command = "find $pic_dir -type f | wc -l";
$count = `$command`;
print "Total find files:$count\n"; }
#測試tmp目錄是否存在,如果不在就建立目錄
if (!-d $dst_dir) {
}
$line_num = 1;
open FILE
, $filename or die "Can't open $filename"; while (<FILE>) {
$p_num = $_;
$HASH{$p_num} = $line_num;
$line_num ++;
}
print_hash_data();
find (\&find_file, $pic_dir); #執行遞迴找圖片檔案
print_file_count();
IyEvdXNyL2Jpbi9wZXJsCnVzZSBGaWxlOjpGaW5kOwp1c2UgRmlsZTo6Q29weTsKdXNlIEZpbGU6OkJhc2VuYW1lOwoKJEhPTUVfZGlyID0gYGVjaG8gXCRIT01FYDsKY2hvbXAgJEhPTUVfZGlyOyAj5Yiq5Y675o+b6KGM56ymCiRkc3RfZGlyID0gJEhPTUVfZGlyLiIvRGVza3RvcC90bXAvIjsgI+ebrueahOi3r+W+kQokcGljX2RpciA9ICRIT01FX2Rpci4iL21hZ2ljL2RpciI7ICPlnJbniYfmqpTnm67pjIQKJGZpbGVuYW1lID0gImxpc3QyLnR4dCI7CiMtLSDpgZ7ov7Tmib7mqpTmoYggLS0Kc3ViIGZpbmRfZmlsZSB7CiAgICAkZGlyID0gJEZpbGU6OkZpbmQ6OmRpcjsKICAgICRmbmFtZSA9ICRGaWx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