#!/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\xD0\xBA\xD0\xB5\xD0\xB1\xD0\xB0\xD0\xBF\xD1\x87\xD0\xB5.txt kebab.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__