Skip to content

Instantly share code, notes, and snippets.

@kazu634
Created December 24, 2011 10:49
Show Gist options
  • Save kazu634/1517110 to your computer and use it in GitHub Desktop.
Save kazu634/1517110 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# for formality's sake
use strict;
use warnings;
# reading directories
opendir(DIR,'.') or die "$!";
my $index = 0;
foreach (readdir(DIR)){
# do something if $_ is directory
if ((-d $_) && ($_ =~ /^[^\.]/)) {
$index++;
printf("mv %s tmpdir%03d\n", $_, $index);
printf("#mv tmpdir%03d %s\n", $index, $_);
};
}
# closing
closedir (DIR);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment