Skip to content

Instantly share code, notes, and snippets.

@hikiko
Last active March 16, 2019 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hikiko/6d3dc2d032861ac5a0ed3ba55cbd4f02 to your computer and use it in GitHub Desktop.
Save hikiko/6d3dc2d032861ac5a0ed3ba55cbd4f02 to your computer and use it in GitHub Desktop.
old script - not tested recently - convert greek to latin fnames (?)
#!/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