Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Rename Windows files with Unicode chars

by Anonymous Monk
on Sep 01, 2016 at 17:08 UTC ( [id://1170991]=note: print w/replies, xml ) Need Help??


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

Another option is with the COM interface,more here:
Unicode issues in Perl (from a windows perspective)
www.i-programmer.info/programming/other-languages/1973-unicode-issues-in-perl.html
  • Comment on Re^2: Rename Windows files with Unicode chars

Replies are listed 'Best First'.
Re^3: Rename Windows files with Unicode chars
by nikosv (Deacon) on Sep 02, 2016 at 04:32 UTC
    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://1170991]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-19 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found