blob: 4f03c14ab4b6b54874d687c35dce4176a4be4ea5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/usr/local/bin/perl
use warnings;
use strict;
use File::Copy qw/mv/;
sub get_og_files
{
my @og_files;
opendir(DIR, '.') or die $!;
while (readdir(DIR)) {
next if ($_ =~ m/^\./);
push @og_files, $_;
}
closedir(DIR);
return @og_files;
}
sub unixize_file_names
{
my @og_files = @_;
my @new_files;
foreach (@og_files) {
if ($_ =~ /^[0-9]+\./) {
$_ =~ s/\.//;
}
$_ =~ s/ - /_/g;
$_ =~ s/ /_/g;
$_ =~ s/c\+\+/cxx/g;
$_ =~ s/C\+\+/CXX/g;
$_ =~ s/[áàåâä]/a/g;
$_ =~ s/[ÁÀÅÂÄ]/A/g;
$_ =~ s/æ/ae/g;
$_ =~ s/Æ/AE/g;
$_ =~ s/ç/c/g;
$_ =~ s/Ç/C/g;
$_ =~ s/[éèêë]/e/g;
$_ =~ s/[ÉÈÊË]/E/g;
ï
î
ì
$_ =~ s/ô/o/g;
$_ =~ s/Ô/O/g;
$_ =~ s/ö/o/g;
$_ =~ s/Ö/O/g;
$_ =~ s/ü/u/g;
$_ =~ s/Ü/U/g;
$_ =~ s/[^A-Za-z0-9\._]+//g;
$_ = lc($_);
push @new_files, $_;
}
return @new_files;
}
sub main
{
my @og_files;
my @new_files;
my @files;
@og_files = get_og_files();
@new_files = unixize_file_names(@og_files);
while (@og_files || @new_files) {
$files[0] = shift @og_files;
$files[1] = shift @new_files;
if (@ARGV == 1 && $ARGV[0] eq '-R' && -d $files[0]) {
chdir($files[0]) or die $!;
main();
chdir('../');
}
next if (-e $files[1]);
mv($files[0], $files[1]) or print STDERR $! . "\n";
print "'". $files[0] . "' -> '" . $files[1] . "'\n";
}
return;
}
main();
__END__
|