in reply to Re^2: rename to UTF8 filename
in thread rename to UTF8 filename
.. 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.... as it showed in monster as well.
???
moveW works for me, start cmd , chcp 65001, perl kebab.pl > keb.txt , type keb.txt, notepad keb.txt
#!/usr/bin/perl -- use strict; use warnings; use Path::Class; use File::Slurp; use Data::Dump; use Win32::Unicode::File; our $thisf = file(__FILE__)->absolute; our $thisd = $thisf->dir; our $tmp = 'fafafa'; chdir $thisd or die sprintf q/ERRRR(%d)(%s)(%d)(%s)/, $!,$!,$^E,$^E; my $names = file('utfnamelist.txt')->absolute; #~ my $bin = read_file( $names, { binmode => ':raw' } ) ; dd $bin; my $bin = "\xEF\xBB\xBF# a utf-8 file-o kebab's\r\nutfnamelist.txt +\xD1\x9B\xD0\xB5\xD0\xB2\xD0\xB0\xD0\xBF.txt\r\n\xD1\x9B\xD0\xB5\xD0\ +xB2\xD0\xB0\xD0\xBF.txt ra\xC5\xBEnji\xC4\x87.txt\r\nra\xC5\ +xBEnji\xC4\x87.txt \xC4\x87evap.txt\r\n\xC4\x87evap.txt + \xD0\xBA\xD0\xB5\xD0\xB1\xD0\xB0\xD0\xBF\xD1\x87\xD0\xB5.txt\r\n\x +D0\xBA\xD0\xB5\xD0\xB1\xD0\xB0\xD0\xBF\xD1\x87\xD0\xB5.txt keb +ab.txt\r\n"; mkdir $tmp or die sprintf q/ERRRR(%d)(%s)(%d)(%s)/, $!,$!,$^E,$^E; chdir $tmp or die sprintf q/ERRRR(%d)(%s)(%d)(%s)/, $!,$!,$^E,$^E; write_file( $names->basename, \$bin ); binmode STDOUT, ':encoding(UTF-8)';print "\x{feff}";#BOM ddir(); open my($fh), '<:encoding(UTF-8)', $names or die sprintf q/ERRRR(%d)(% +s)(%d)(%s)/, $!,$!,$^E,$^E; while(<$fh>){ next if $. == 1; # /#/; my( $here, $there ) = split /\s+/, $_; next unless $here and $there; print "# moveW $here => $there\n"; #~ dd [ $here, $there ]; moveW( $here, $there ) or die sprintf q/ERRRR(%d)(%s)(%d)(%s)/, $ +!,$!,$^E,$^E; ddir(); } chdir '..'; dir($tmp)->rmtree("verbose","cautious"); sub ddir { my $dir = `cmd /x /c "dir /b "`;; #~ use Encode::Detective qw' detect '; #~ warn detect($dir) ; # "UTF-8" utf8::decode($dir); print "# dir # ", $dir ; } __END__
# dir # utfnamelist.txt # moveW utfnamelist.txt => ћевап.txt # dir # ћевап.txt # moveW ћевап.txt => ražnjić.txt # dir # ražnjić.txt # moveW ražnjić.txt => ćevap.txt # dir # ćevap.txt # moveW ćevap.txt => кебапче.txt # dir # кебапче.txt # moveW кебапче.txt => kebab.txt # dir # kebab.txt unlink fafafa\kebab.txt rmdir fafafa
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: rename to UTF8 filename
by exilepanda (Friar) on Jul 30, 2012 at 08:37 UTC | |
by Anonymous Monk on Jul 30, 2012 at 09:36 UTC | |
by exilepanda (Friar) on Jul 31, 2012 at 04:06 UTC | |
by Anonymous Monk on Aug 13, 2012 at 10:53 UTC | |
by Anonymous Monk on Jul 30, 2012 at 08:40 UTC |
In Section
Seekers of Perl Wisdom