Skip to content

Instantly share code, notes, and snippets.

@parastuffs
Last active August 29, 2015 14:15
Show Gist options
  • Save parastuffs/5804db452f25cd2ee36a to your computer and use it in GitHub Desktop.
Save parastuffs/5804db452f25cd2ee36a to your computer and use it in GitHub Desktop.
Rename batch
#!/usr/bin/env perl
use strict;
use warnings;
use String::CRC32;
use File::Copy;
my (@files);
open(FD1, "ls *.mp4 *.mkv |");
@files = <FD1>;
close(FD1);
foreach my $f (@files) {
chomp $f;
open(FD1, $f);
my $crc = crc32(*FD1);
close(FD1);
$crc = uc sprintf('%08x', $crc);
$f =~ m/.*\ ([\d][\d][\d]).*\.(.{3})$/g;
my $newname = "[VOSTFR]_Bleach_-_$1_[$crc].$2";
print "$f is becoming $newname\n";
rename("$f", "$newname");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment