Created
July 11, 2012 13:54
-
-
Save myokoym/3090502 to your computer and use it in GitHub Desktop.
全角ファイル名の文字コードを再帰的に変換するスクリプト(convmvがインストールできない環境のため自作)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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