Created
November 19, 2014 22:40
-
-
Save tadzik/e2e6bbe20e94f572dac9 to your computer and use it in GitHub Desktop.
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
┌─[tadzik@yavin]─[/tmp] | |
└─[%]─> ls chuj | |
DUPA script.pl | |
┌─[tadzik@yavin]─[/tmp] | |
└─[%]─> /usr/bin/perl chuj/script.pl chuj | |
No need to move chuj/script.pl, it is already in lower case. | |
/tmp/chuj | |
Moving chuj/DUPA to chuj/dupa... | |
┌─[tadzik@yavin]─[/tmp] | |
└─[%]─> ls chuj | |
DUPA script.pl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use strict;
use warnings;
use File::Copy;
use File::Find;
use Cwd 'cwd';
find(&lowercase, @argv);
sub lowercase {
if ($_ eq '.') {
return 0;
};
my $original = $File::Find::name;
$_ =~ s/(^.*)/\L$1/g;
my $lowercased = $File::Find::dir . '/' . $_;
if ($original eq $lowercased) {
CORE::say 'No need to move ' . $original . ', it is already in lower case.';
return 0;
}
CORE::say cwd();
CORE::say 'Moving ' . $original . ' to ' . $lowercased . '...';
move("$original", "$lowercased");
}