[[Perl]] +Shift-JISなどのtxtファイルをUTF-8へ変換するスクリプト @ls = `ls *.txt`; chomp @ls; foreach$file(@ls){ $file_utf8 = $file; $file_utf8 =~ s/\.(.*)?$//; $file_utf8.= ".utf8"; system("nkf -w $file > tmp"); system("mv tmp $file_utf8"); print "nkf -w $file > tmp\n"; } +ディレクトリ構造になっている場合、Shift-JISなどのtxtファイルをUTF-8へ変換するスクリプト --use File::Findを利用した再帰的な方法 use File::Find; @ARGV = qw(.) unless @ARGV; find sub { push @list, $File::Find::name, -d && '/', "\n"}, @ARGV; chomp @list; foreach(@list){ unless($_){next;} if(/^\//){next;} print "nkf -w $_ > tmp\n"; system("nkf -w $_ > tmp"); system("mv tmp $_"); }