Skip to content

Instantly share code, notes, and snippets.

@sinkovsky
Created June 13, 2010 21:34
Show Gist options
  • Save sinkovsky/437025 to your computer and use it in GitHub Desktop.
Save sinkovsky/437025 to your computer and use it in GitHub Desktop.
use File::Find;
use File::Copy;
use Cwd;
use File::Path qw(make_path);
my $workdir = getcwd;
find(sub {
return if -d;
return if -l;
return if /^\./;
if ( my ($subdir) = $_ =~ /([^[CF]+)[CF\d#]+.wav/ ) {
my $subdir_path = $workdir."/".$File::Find::dir."/".$subdir;
print "Creating subdir: $subdir_path\n";
make_path $subdir_path;
my $old = $workdir."/".$File::Find::name;
my $new = $workdir."/".$File::Find::dir."/".$subdir."/".$_;
print "Renaming ", $old, "-> ", $new,"\n";
move $old, $new or die "Can't rename, $!";
}
}, "foobar");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment