Perl 递归文件搜索 unicode 文件名
我尝试过 File::Find::Rule
,但它没有显示包含以下字符的文件名: בר רפאלй
有什么想法吗?
use File::Find::Rule;
use Win32::Shortcut;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new('status.xls');
my $worksheet = $workbook->add_worksheet();
my $base_dir ='E:/files/';
my $find_rule = File::Find::Rule->new;
#$find_rule->maxdepth(1);
$find_rule->name('*.lnk');
my @files = $find_rule->in($base_dir);
print scalar(@files)."\n";
#print join("\n", @files);
I've tried File::Find::Rule
, but it doesn't reveal filenames that contain characters like:בר רפאלי
Any ideas?
use File::Find::Rule;
use Win32::Shortcut;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new('status.xls');
my $worksheet = $workbook->add_worksheet();
my $base_dir ='E:/files/';
my $find_rule = File::Find::Rule->new;
#$find_rule->maxdepth(1);
$find_rule->name('*.lnk');
my @files = $find_rule->in($base_dir);
print scalar(@files)."\n";
#print join("\n", @files);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有办法测试这个(Linux,没有太多的 Unicode 知识等),它可能效率低下,但也许它会以“只是完成它的方式”工作。你可以使用我的
File::chdir::WalkDir
并使用每个文件的回调添加到文件名至列表:由于这依赖于
opendir
和朋友,因此可能会很慢,但只要它可以看到您的文件,就应该可以尝试一下,如果有问题请告诉我。I have no way to test this (Linux, not too much Unicode knowledge etc) and its probably inefficient, but perhaps it will work in a "just get it done kind of way. You could use my
File::chdir::WalkDir
and use a per-file callback that adds to the file name to a list:Since this leans on
opendir
and friends it may be slow, but as long as it can see your files, this should work. Give it a try and let me know if there are problems.请参阅 Win32::Unicode::Native 和 http://perlmonks.com/?node_id=843602
see Win32::Unicode::Native and http://perlmonks.com/?node_id=843602