-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmake-lowercase
executable file
·63 lines (54 loc) · 1.37 KB
/
make-lowercase
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
#!/usr/bin/perl
my $top=`pwd`; chomp $top;
sub vfat_rename($$) {
my $from,$to;
($from,$to) = @_;
# uppercase DOS names with the vfat driver need some forceful convincing
# to actually make them lowercase
rename($from,"$to.xxx.xx");
rename("$to.xxx.xx",$to);
}
sub scan($) {
my $old = `pwd`; chomp $old;
my $cur = shift @_;
my @x;
print "scanning $cur\n";
chdir($cur) || die;
opendir(X,".") || return;
while (my $name = readdir(X)) {
next unless -f $name;
my $n = lc($name);
next if $n eq $name;
print "$name\n";
rename($name,$n) || die;
vfat_rename($name,$n);
}
closedir(X);
opendir(X,".") || return;
while (my $name = readdir(X)) {
next if $name =~ m/^\.+$/;
next if $name eq ".git";
next if $name eq ".GIT";
next unless -d $name;
my $n = lc($name);
next if $n eq $name;
print "$name\n";
rename($name,$n) || die;
vfat_rename($name,$n);
}
closedir(X);
opendir(X,".") || return;
while (my $name = readdir(X)) {
next if $name =~ m/^\.+$/;
next if $name eq ".git";
next if $name eq ".GIT";
next unless -d $name;
push(@x,$name);
}
closedir(X);
foreach my $name (@x) {
scan("$cur/$name");
}
chdir($old) || die;
}
scan($top);