Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created November 19, 2014 22:40
Show Gist options
  • Save tadzik/e2e6bbe20e94f572dac9 to your computer and use it in GitHub Desktop.
Save tadzik/e2e6bbe20e94f572dac9 to your computer and use it in GitHub Desktop.
┌─[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
@tadzik
Copy link
Author

tadzik commented Nov 19, 2014

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");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment