Skip to content

Instantly share code, notes, and snippets.

@myokoym
Created July 11, 2012 13:54
Show Gist options
  • Save myokoym/3090502 to your computer and use it in GitHub Desktop.
Save myokoym/3090502 to your computer and use it in GitHub Desktop.
全角ファイル名の文字コードを再帰的に変換するスクリプト(convmvがインストールできない環境のため自作)
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use File::Copy;
use Encode;
my $target_dir = $ARGV[0];
my $option = $ARGV[1];
finddepth(\&convmv_euc_to_sjis, $target_dir);
sub convmv_euc_to_sjis() {
my $conv = $_;
Encode::from_to($conv, 'euc-jp', 'shiftjis');
return if ($_ eq $conv);
if ($option && $option eq "--notest") {
move $_, $conv or die $!;
} else {
print $File::Find::dir . "/" . $conv . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment