Last active
March 16, 2019 10:33
-
-
Save hikiko/6d3dc2d032861ac5a0ed3ba55cbd4f02 to your computer and use it in GitHub Desktop.
old script - not tested recently - convert greek to latin fnames (?)
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 Encode; | |
use File::Copy; | |
my $dir; | |
my @files; | |
my $file; | |
my $initfile; | |
my $flag; | |
$dir=$ARGV[0]; | |
if ( -d $dir ) { | |
opendir (DIR,$dir) or die $!; | |
@files = (readdir DIR) or die $!; | |
closedir (DIR) or die $!; | |
foreach ( @files ) { | |
next if ( $_ eq "." || $_ eq ".." ); | |
$file = $_; | |
$initfile = $_; | |
$flag = decode ("utf8",$_,Encode::FB_QUIET); | |
if ( $flag ) { | |
$file = encode("iso-8859-7",$flag); | |
} | |
$file =~ s/\s/_/g; | |
$file =~ s/θ/th/g; | |
$file =~ s/Θ/th/g; | |
$file =~ s/ψ/ps/g; | |
$file =~ s/Ψ/ps/g; | |
$file =~ tr/ΑΒΓΔΕΖΗΙΚΛΜΝΞΟΠΡΣΤΥΦΧΩΆΈΉΊΎΌΏΪΫαβγδεζηικλμνξοπρστυφχωάέήίύόώϋϊΰΐς/abgdeziiklmnxoprstyfhoaeiiyooiyabgdeziiklmnxoprstyfhoaeiiyooyiyis/; | |
$file =~s/_-_/-/g; | |
$file = "\L$file"; | |
move("$dir$initfile","$dir$file") || die $!; | |
if ( $initfile eq $file ) { | |
print "Filename $initfile has not been changed.\n"; | |
} | |
else { | |
print "Filename $initfile has been changed to $file.\n"; | |
} | |
} | |
} | |
else { | |
print "Dir not found.\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment