blob: 01ba9da7d996c99968acafefe4258d593a91741f (
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
 | #! /usr/bin/perl
# /bin/sh : NEW=`ls | sed s/\ /_/g | sed s/_-_/_/g `
sub proceed{
	my $dir=shift;
	my $prefix=shift;
	opendir(DIRHANDLE,$dir) || die "Cannot open dir $dir";
	while ($name=readdir(DIRHANDLE)){
        if($name =~m/^\./){
            next;
        }
        my $ustring = "\x{b4}";
		my $new = $name;
        $new =~ s/ /_/g;
        $new =~ s/'/_/g;
        $new =~ s/[\[\]]/_/g;
        $new =~ s/$ustring/_/g;
        $new =~ s/\._/_/g;
        $new =~ s/_+\./\./g;
        $new =~ s/[_-](-*_*)+/_/g;
        $new =~ s/\\/-/g;
        $new =~ s/\\/-/g;
        if(defined($prefix)){
            $new =~ s/^$prefix//g;
        }
        if ($name ne $new) {
            rename($name, $new) || die "Unable to rename $name in $new.";
        }
    }
	closedir(DIRHANDLE);
}
proceed(".", shift);
 |