Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Rename Windows files with Unicode chars

by nikosv (Deacon)
on Sep 02, 2016 at 04:32 UTC ( [id://1171036]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Rename Windows files with Unicode chars
in thread Rename Windows files with Unicode chars

thanks for the mention. The article goes to lengths in describing the underlying encoding issues and how to deal with them,but for the OP's purpose the following code snippet extracted from the article should do it
use Win32::Console; Win32::Console::OutputCP( 65001 ); use Devel::Peek; use Win32::OLE qw(in); binmode(STDOUT, ":utf8"); Win32::OLE->Option(CP => Win32::OLE::CP_UTF8); $obj = Win32::OLE-> new('Scripting.FileSystemObject'); $folder = $obj->GetFolder("."); $collection= $folder->{Files}; foreach $value (in $collection) { $filename= %$value->{Name}; next if ($filename !~ /.rar/i); print $filename,"\n"; Dump $filename,"\n"; }
I haven't benchmarked it but logically the Win32 API calls should be faster than calling into the COM,but nevertheless COM exposes FileSystemObjects methods which might be convenient anyway

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1171036]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-23 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found