Skip to content

Commit

Permalink
Added script that will lowercase all files in a directory tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 19, 2016
1 parent a7f69be commit 0484d69
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lowerfiles
@@ -0,0 +1,40 @@
#!/usr/bin/perl -w

use warnings;
use strict;


sub walkdir {
my $d = shift;
opendir(DIRH, $d) or die("Couldn't open directory [$d]: $!");
my @dirfiles = readdir(DIRH);
closedir(DIRH);
foreach (@dirfiles) {
my $dent = $_;
next if $dent eq '.';
next if $dent eq '..';
doLowering($d . '/' . $dent);
}
}

sub doLowering {
my $path = shift;
my $l = $path;
$l =~ tr/A-Z/a-z/;
print("Lowercasing $path ...\n");
rename $path,$l or die("Failed to rename '$path' to '$l': $!\n");
if (-d $l) {
print("Walking $path ...\n");
walkdir($path);
}
}


# Mainline ...

foreach (@ARGV) {
doLowering($_);
}

# end of lowerfiles ...

0 comments on commit 0484d69

Please sign in to comment.