Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks for reply. Um.. to narrow down the err possibility, I've cut and paste the 2 cols into a text file, use notepad, and save as UTF-8. But please tell me if that still not the version that Perl happy with. Here's my code and there are 2 paths see the remarked lines as version 2 :
use Win32API::File 0.08 qw( :ALL ); #use Win32::Unicode::File; binmode STDOUT, ":utf8"; open F, "Result_fineName.txt"; #binmode F, ":utf8"; # binmode or not still won't work my @list = <F>; close F; chomp @list; my %hash; foreach (@list) { my ( $id, $name ) = split /\t/, $_, 2; $name =~ s/[\\\/\<\>\?\:\|\*]/ /g; $name =~ s/ {2,}/ /g; $hash{$id} = $name; } chdir ( "./doRename/2.4" ) ; my $source = `dir /b`; my @src = split /\n/, $source; chomp @src; foreach my $f ( @src ) { my @parts = split /[ _]/, $f; print $f ; MoveFile $f, "$hash{$parts[1]}.mp3" or print fileLastError() ; #W +in32API::File #moveW $f, "$hash{$parts[1]}.mp3" or print errorW; # Win32::Un +icode::File print $/; }
There are 2 sample files in folder 2.4.
One will rename to a file name starts with ANSI char. If I use the Win32API::File way, there is no error raised, it do the rename, but it turns into monster char.
If I use the Win32::Unicode::File way, it raised an err Undefined subroutine Errno::ERROR_FILE_EXISTS called at C:/Perl/site/lib/Unicode/ line 31.

The other will rename to a pure Japanese file name.
If I use the Win32API::File way, it rasied an err : The filename, directory name, or volume label syntax is incorrect
If use the Win32::Unicode::File way, it does nothing, no err, and no rename.

Note, before I run this from my cmd prompt, I've changed codepage to 65001. Without this, the error message will raise in Chinese ( I guess ), as it showed in monster as well.

In reply to Re^2: rename to UTF8 filename by exilepanda
in thread rename to UTF8 filename by exilepanda

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2018-05-28 08:36 GMT
    Find Nodes?
      Voting Booth?